Yahoo! UI Library

yuiloader  2.9.0

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

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

_useYahooListener - private object

Use the YAHOO environment listener to detect script load. This is only switched on for Safari 2.x and below.

allowRollup - boolean

Should we allow rollups
Default Value: true

base - string

The base directory.
Default Value:[YUI VERSION]/build/

charset - string

The charset attribute for inserted nodes
Default Value: utf-8

combine - boolean

If configured, YUI will use the the combo handler on the Yahoo! CDN to pontentially reduce the number of http requests required.
Default Value: false

comboBase - string

Base path for the combo service
Default Value:

data - object

Data that is passed to all callbacks

dirty - boolean

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

filter - string|{searchExp: string, replaceStr: string}

A filter to apply to result urls. This filter will modify the default path for all modules. The default path for the YUI library is the minified version of the files (e.g., event-min.js). The filter property can be a predefined filter or a custom filter. The valid predefined filters are:
Selects the debug versions of the library (e.g., event-debug.js). This option will automatically include the logger widget
Selects the non-minified version of the library (e.g., event.js).
You can also define a custom filter, which must be an object literal containing a search expression and a replace string:
myFilter: {
'searchExp': "-min\\.js",
'replaceStr': "-debug.js"

force - string[]

A list of modules that should always be loaded, even if they have already been inserted into the page.

ignore - string[]

A list of modules that should not be loaded, even if they turn up in the dependency tree

insertBefore - string|HTMLElement

Node reference or id where new nodes should be inserted before

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

root - string

Root path to prepend to module path for the combo service
Default Value: [YUI VERSION]/build/

scope - object

The execution scope for all callbacks
Default Value: this

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: // 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

timeout - int

Timeout value in milliseconds. If set, this value will be used by the get utility. the timeout event will fire if a timeout occurs.

varName - string

The name of the variable in a sandbox or script node (for external script support in Safari 2.x and earlier) to reference when the load is complete. If this variable is not available in the specified scripts, the operation will fail.



private string _addSkin ( skin , mod )
Adds the skin def to the module info
skin <string> the name of the skin
mod <string> the name of the module
Returns: string
the module name for the skin


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


private string _filter ( )
Applies filter method _filter
Returns: string
the filtered string


private void _pushEvents ( optional )
In IE, the onAvailable/onDOMReady events need help when Event is loaded dynamically
optional <Function> function reference


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


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()


private void _setup ( )
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()


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


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.
required, the component name
required, the component type (js or css)
required, the path to the script from "base"
array of modules required by this component
array of optional modules for this component
array of the modules this component replaces
array of modules the components which, if present, should be sorted above this one
the number of superseded modules required for automatic rollup
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


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


getProvides ( name , notMe )
Returns an object literal of the modules the supplied module satisfies
name <string> The name of the module
notMe <string> don't add this module name, only include superseded modules
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


void insert ( 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.
o <object> optional options object
type <string> the type of dependency to insert


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)


void onFailure ( )
Callback that will be executed if there is a failure


void onProgress ( )
Callback that will be executed each time a new module is loaded


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


void onTimeout ( )
Callback that will be executed if a timeout occurs


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


void sandbox ( callback )
Interns the script for the requested modules. The callback is provided a reference to the sandboxed YAHOO object. This only applies to the script: css can not be sandboxed; css will be loaded into the page normally if specified.
callback <Function> the callback to exectued when the load is complete.

Copyright © 2011 Yahoo! Inc. All rights reserved.