Javascript lazy loading with dependencies

Here it is, yet another javascript lazy loader. Sadly, none of existing ones has been solving my problem and I was even using great $script.js for some time, but eventually written new one.



Sample usage:

// Adding to queue:

$scru.queue('google:jsapi', $scru.fn.async_load(''));
$scru.queue('google:visualization', $scru.fn.google_load('visualization', '1', {packages:['corechart']}), ['google:jsapi']);

// Somewhere in some script (called only when needed)

$scru.execute(drawChart, ['google:visualization']);

All jsapi, visualization js are loaded only when “execute” is called.

  1. by sobstel • December 2011