YUI recommends YUI 3.

YUI 2 has been deprecated since 2011. This site acts as an archive for files and documentation.

Yahoo! UI Library

yuiloader  2.3.1

Yahoo! UI Library > yuiloader > YAHOO.util.YUILoader

Show Private Show Protected

Class YAHOO.util.YUILoader

YUILoader provides dynamic loading for YUI.


_internalCallback - private object

Internal callback to handle multiple internal insert() calls so that css is inserted prior to js

allowRollup - boolean

Should we allow rollups
Default Value: true

base - string

The base directory.
Default Value: build

dirty - boolean

Flag to indicate the dependency tree needs to be recomputed if insert is called again.
Default Value: true

filter - string|object

Filter to apply to result url

inserted - {string: boolean}

List of modules inserted by the utility

loaded - {string: boolean}

Set when beginning to compute the dependency tree. Composed of what YAHOO reports to be loaded combined with what has been loaded by the tool

loadOptional - boolean

Whether or not to load optional dependencies for the requested modules
Default Value: false

moduleInfo - object

The library metadata

required - {string: boolean}

The list of requested modules

rollups - object

List of rollup files found in the library metadata

sandbox - boolean

Create a sandbox rather than inserting into lib into. the current context. Not currently supported property sandbox
Default Value: false

skin - object

Provides the information used to skin the skinnable components. The following skin definition would result in 'skin1' and 'skin2' being loaded for calendar (if calendar was requested), and 'sam' for all other skinnable components: skin: { // The default skin, which is automatically applied if not // overriden by a component-specific skin definition. // Change this in to apply a different skin globally defaultSkin: 'sam', // This is combined with the loader base property to get // the default root directory for a skin. ex: // http://yui.yahooapis.com/2.3.0/build/assets/skins/sam/ base: 'assets/skins/', // The name of the rollup css file for the skin path: 'skin.css', // The number of skinnable components requested that are // required before using the rollup file rather than the // individual component css files rollup: 3, // Any component-specific overrides can be specified here, // making it possible to load different skins for different // components. It is possible to load more than one skin // for a given component as well. overrides: { calendar: ['skin1', 'skin2'] } }

sorted - string[]

All of the derived dependencies in sorted order, which will be populated when either calculate() or insert() is called



private void _addSkin ( )
Adds the skin def to the module info
Returns: void


private void _explode ( )
Inspects the required modules list looking for additional dependencies. Expands the required list to include all required modules. Called by calculate()
Returns: void


private void _pushEvents ( )
In IE, the onAvailable/onDOMReady events need help when Event is loaded dynamically
Returns: void


private void _reduce ( )
Remove superceded modules and loaded modules. Called by calculate() after we have the mega list of all dependencies
Returns: void


private void _rollup ( )
Look for rollup packages to determine if all of the modules a rollup supersedes are required. If so, include the rollup to help reduce the total number of connections required. Called by calculate()
Returns: void


private void _setup ( o )
Investigates the current YUI configuration on the page. By default, modules already detected will not be loaded again unless a force option is encountered. Called by calculate()
o <object> optional options object
Returns: void


private void _skin ( )
Sets up the requirements for the skin assets if any of the requested modules are skinnable
Returns: void


private void _sort ( )
Sorts the dependency tree. The last step of calculate()
Returns: void


private string _url ( path )
Generates the full url for a module method _url
path <string> the path fragment
Returns: string
the full url


boolean addModule ( o )
Add a new module to the component metadata. The javascript component must also use YAHOO.register to notify the loader when it has been loaded, or a verifier function must be provided
required, the component name
required, the component type (js or css)
required, the path to the script from "base"
the modules required by this component
the optional modules for this component
the modules this component replaces
the number of superseded modules required for automatic rollup
a function that is executed to determine when the module is fully loaded
If fullpath is specified, this is used instead of the configured base + path
flag to determine if skin assets should automatically be pulled in
o <object> An object containing the module data
Returns: boolean
true if the module was added, false if the object passed in did not provide all required attributes


void calculate ( o )
Calculates the dependency tree, the result is stored in the sorted property
o <object> optional options object
Returns: void


string formatSkin ( skin , mod )
Returns the skin module name for the specified skin name. If a module name is supplied, the returned skin module name is specific to the module passed in.
skin <string> the name of the skin
mod <string> optional: the name of a module to skin
Returns: string
the full skin module name


void getProvides ( mod )
Returns an object literal of the modules the supplied module satisfies
mod <object> The module definition from moduleInfo
Returns: void
what this module provides


void getRequires ( mod )
Returns an object containing properties for all modules required in order to load the requested module
mod <object> The module definition from moduleInfo
Returns: void


void insert ( callback , o , type )
inserts the requested modules and their dependencies. type can be "js" or "css". Both script and css are inserted if type is not provided.
callback <Function> a function to execute when the load is complete.
o <object> optional options object
type <string> the type of dependency to insert
Returns: void


void insertCss ( url , win )
Inserts a css link node
url <string> the full url for the script
win <Window> optional window to target
Returns: void


void insertScript ( url , win )
Inserts a script node
url <string> the full url for the script
win <Window> optional window to target
Returns: void


void loadNext ( mname )
Executed every time a module is loaded, and if we are in a load cycle, we attempt to load the next script. Public so that it is possible to call this if using a method other than YAHOO.register to determine when scripts are fully loaded
mname <string> optional the name of the module that has been loaded (which is usually why it is time to load the next one)
Returns: void


void onLoadComplete ( )
Callback that will be executed when the loader is finished with an insert
Returns: void


skin: string, module: string parseSkin ( mod )
Reverses formatSkin, providing the skin name and module name if the string matches the pattern for skins.
mod <string> the module name to parse
Returns: skin: string, module: string
the parsed skin name and module name, or null if the supplied string does not match the skin pattern


void require ( what )
Add a requirement for one or more module
what <string[] | string*> the modules to load
Returns: void

Copyright © 2007 Yahoo! Inc. All rights reserved.