PHP Loader, originally written by longtime YUI engineer Adam Moore and now developed and maintained by fellow Yahoo Chad Auld, has several key features that make it easier to use YUI in PHP-based applications:
- Reliable, sorted loading of dependencies: You specify the version of YUI that you’re using, the modules you want to use, and PHP Loader outputs the requisite
csstags for your implementation. Even if YUI’s dependency tree changes in a future version, your code won’t have to.
- Support for performance best-practices: PHP Loader has three strategies to help you reduce HTTP requests — support for the Yahoo! CDN and its combo-handler (which aggregates YUI files into single HTTP requests on the fly), support for YUI’s rollup files, and (in the event you don’t want to serve YUI from Yahoo!’s servers) a lightweight combo-handler of its own. Server-side performance is fast as well, leveraging PHP’s APC cache.
PHP Loader is simple to use:
include("loader.php"); $loader = new YAHOO_util_Loader("2.7.0"); //Configure your instance; for example, you can turn off rollups $loader->allowRollups = false; //Specify YUI components to load $loader->load("yahoo", "dom", "event", "tabview", "grids", "fonts", "reset"); //Output the tags (this call would most likely be placed in the document head) $loader->tags();
The above PHP script would output the following to the page:
Leveraging the combo-handler on Yahoo!’s servers, you can flip the
combine setting on…
$loader->combine = true;
YUI PHP Loader links:
- Read the documentation
- Download the latest release, including functional examples, from YUILibrary.com
- File bug reports or feature requests on YUILibrary.com
- YUI PHP Loader is hosted on GitHub, where you grab the latest source
Welcoming a New YUI Contributor: Chad Auld
Chad Auld has driven the release of PHP Loader, and big thanks are owed to him for taking ownership of this application and adding a series of fantastic features as he prepped it for this beta release. You may know Chad from his work on MiaCMS and the Sideline AIR application for Twitter search. We’ve been looking for an opportunity to collaborate with him for awhile, and we couldn’t be happier to have that happening on this project.