LazyLoad makes it easy and painless to lazily load one or more JavaScript files on demand after a web page has been rendered.
Supported browsers include Firefox 2.x, Firefox 3.x, Internet Explorer 6.x, Internet Explorer 7.x, Safari 3.x (including iPhone), and Opera 9.x. Other browsers may or may not work and are not officially supported.
Ryan Grove (ry@wonk o.com) an
Copyright © 2008 Ryan Grove (ry@wonk o.com). All rights reserved. an
BSD License (http://www.opensource.org
http://wonko.com
1.0.4 (2008-07-24)
LazyLoad | LazyLoad makes it easy and painless to lazily load one or more JavaScript files on demand after a web page has been rendered. |
Private Variables | |
d | Shorthand reference to the browser’s document object. |
pending | Pending request object, or null if no request is in progress. |
queue | Array of queued load requests. |
ua | User agent information. |
Private Methods | |
getUserAgent | Populates the ua variable with user agent information. |
Public Methods | |
load | Loads the specified script(s) and runs the specified callback function when all scripts have been completely loaded. |
loadOnce | Loads the specified script(s) only if they haven’t already been loaded and runs the specified callback function when loading is complete. |
requestComplete | Handles callback execution and cleanup after a request is completed. |
load: function ( urls, callback, obj, scope )
Loads the specified script(s) and runs the specified callback function when all scripts have been completely loaded.
urls | URL or array of URLs of scripts to load |
callback | function to call when loading is complete |
obj | (optional) object to pass to the callback function |
scope | (optional) if true, callback will be executed in the scope of obj instead of receiving obj as an argument. |
loadOnce: function ( urls, callback, obj, scope, force )
Loads the specified script(s) only if they haven’t already been loaded and runs the specified callback function when loading is complete. If all of the specified scripts have already been loaded, the callback function will not be executed unless the force parameter is set to true.
urls | URL or array of URLs of scripts to load |
callback | function to call when loading is complete |
obj | (optional) object to pass to the callback function |
scope | (optional) if true, callback will be executed in the scope of obj instead of receiving obj as an argument |
force | (optional) if true, callback will always be executed, even if all specified scripts have already been loaded |
Shorthand reference to the browser’s document object.
var d
Pending request object, or null if no request is in progress.
pending
Array of queued load requests.
queue
User agent information.
ua
Populates the ua variable with user agent information.
function getUserAgent()
Loads the specified script(s) and runs the specified callback function when all scripts have been completely loaded.
load: function ( urls, callback, obj, scope )
Loads the specified script(s) only if they haven’t already been loaded and runs the specified callback function when loading is complete.
loadOnce: function ( urls, callback, obj, scope, force )
Handles callback execution and cleanup after a request is completed.
requestComplete: function ()