YUI 3.x Home -

YUI Library Examples: The YUI Global Object: Load All Modules

Note: This is YUI 3.x. Looking for YUI 2.x?

The YUI Global Object: Load All Modules

This example shows how to work with all the modules that are available on a page.

Including YUI and Additional Modules on the Page

Here we are including any additional dependencies we need within the page instead of relying on loader to pull them in dynamically.

Setting up the YUI Instance

When we create our YUI instance, we'll tell it to load the * module.

The * module is a shorthand module name for all modules on the page. This way you don't have to supply the full list of requirements to the use method.

Using the callback

You can pass a function as the last argument to the use. This function will execute after the YUI instance loads all the modules.

The function is supplied one argument: the YUI instance that we have just created. When this function executes, all of the modules have been loaded and attached to the instance, ready to use.

Now that we know all of the modules are loaded, we will show a list of the modules loaded in this YUI instance.

Copyright © 2009 Yahoo! Inc. All rights reserved.

Privacy Policy - Terms of Service - Copyright Policy - Job Openings