JSLoad

Doc : Examples

Example 1: Lazy Loading

The gray box below is populated by script, but that script depends on prototype.js to work. JSLoad works lazily, though, only loading things when it needs them.

While loading, the box is populated with a simple test that confirms that prototype.js is not, in fact, loaded. Once you click "Run Test," however, JSLoad will find that it needs prototype.js to load the script. It will then load prototype.js and execute the script as a callback.