YUI PHP Loader Utility: Local Combo Handler

In this example, we bring a number of YUI components onto the page using the YUI PHP Loader Utility. This example implements YUI PHP Loader via a YAHOO_util_Loader instance. We include the YUI PHP Loader script file, then specify in configuration which component we want loaded on the page. The key difference between this and other samples is the use of a local combo handler. YUI PHP Loader ships with intrinsic combo-handling support. This feature will allow YUI PHP Loader to combine files without relying on a remote combo-service such as the one outlined here. It should also prove useful in environments where SSL is required and/or where including scripts from remote servers is prohibited.

Use Case: Using the Local Combo Handler

This example implements the YUI PHP Loader Utility to load the Calendar Control. This example is almost identical to the advanced example outlined here. The only major difference is that we are enabling the combo handling service and overriding the default the combo service location. By default when combo handling is requested YUI PHP Loader will serve files from Yahoo! servers; see "Serving YUI Files from Yahoo!" for important information about this service.

Here's what that looks like in terms of raw source — this is the full source code for this example:

This code executes the following steps in order:

  1. YUI PHP Loader loads taking the configuration settings into account. It gets instructions about what components are required and how to configure them.
  2. Combine option is enabled and the local combo handler is requested. The combo request will be made to the local combo handler instead of the remote combo handling service. The local combo handler will disassemble the combo url and setup YUI PHP Loader with the desired version and components.
  3. YUI PHP Loader checks the dependency tree. The local combo handler returns a single cacheable JavaScript or CSS file. Separate requests must be made for each resource type via the script and css methods.