array( "name" => 'customJS', "type" => 'js', // 'js' or 'css' "fullpath" => './assets/custom/data.js', // overrides path "requires" => array("event", "dom", "json") ), "customCSS" => array( "name" => 'customCSS', "type" => 'css', // 'js' or 'css' "fullpath" => './assets/custom/custom.css', // overrides path ) ); //Get a new YAHOO_util_Loader instance which includes our custom metadata along with the base YUI metadata //Note: rand is used here to help cache bust the example $loader = new YAHOO_util_Loader($yuiCurrentVersion, 'my_custom_config_'.rand(), $customModules); $loader->load("customJS", "customCSS"); ?> YUI PHP Loader Utility Example: Adding Custom Modules with YUI Dependencies css(); ?>

YUI PHP Loader Utility Example: Adding Custom Modules with YUI Dependencies

The YUI PHP Loader Utility is designed, of course, to help you put YUI components on the page. While the YUI PHP Loader is great at loading YUI resources it is important to point out that it can also be a great resource for loading custom non-YUI JavaScript and CSS resources on the page as well. These can be mixed in with YUI dependencies and/or be all custom modules.

This example shows you how to create a set of custom (non-YUI) modules that have YUI component dependencies and load them via YUI PHP Loader.

For this example we will load some local JSON data and a custom CSS module via the YUI PHP Loader Utility. The custom JavaScript module, customJS, defines dependencies on the YUI DOM, Event, and JSON components so the YUI PHP loader will load these for us as well. When the document is loaded we will process the JSON data with the JSON utility, create additional unordered list items with that data, and apply a CSS class to the last item which will use custom styles defined in our custom CSS module.

An example without YUI dependencies can be found here. To make the examples easier to follow the code preforms the exact same functionality. The biggest difference between these two examples is the usage of YUI Components. The source for this example, including the server-side PHP code, can be seen here.

script(); ?>