Using addModule to Add Custom (Non-YUI) Content with YUILoader

The YUILoader Utility is designed, of course, to help you put YUI components on the page. But your applications will frequently consist of a YUI-component foundation with your own application logic built on top. In other words, when you're loading YUI components you'll often want to load your own components as well.

This example shows you how to create a custom (non-YUI) module and load it via YUILoader. Click the "Load Yahoo! Maps" button below to load the Yahoo! Maps widget using the Yahoo! Maps AJAX API. The Maps widget requires specific YUI functionality to be loaded before its own JavaScript files are loaded. YUI Loader accepts our definition of a new yahoomaps module and, when we request it, the required files are brought into the page in the correct order.

Note 1: As of YUI 2.4.1, defining custom modules that override existing YUI skins requires a specific syntax. See the example code below for details. Note 2: Opera is not fully supported by the Yahoo! Maps AJAX API.

Click the button above; Yahoo! Maps will load here.