Call (877) SITE-OPT (748-3678)

Code: Lazy-load your JavaScript

Chapter 8 - Ajax Optimization

Many JavaScript libraries employ a form of “lazy-loading” or on-demand fetching by which code is loaded only when necessary. For example, you might employ this:

window.onload = function ( ) {
lazyCodeLoad(["",""]) }

where the function defined reads each URI in the array and just creates a script tag using the DOM. It then sets its source to the file in question and inserts it into the page to retrieve it.

Copyright © 2002-2018 Website Optimization, LLC. All Rights Reserved - Free website speed test - Privacy Policy
Last modified: February 19, 2009.

Follow us on: Twitter, Google+, Facebook, Linked In