Author: Jon Davis <jon@jondavis.net>
Current Version: 1.3.1
Released: April 17, 2008
Download from: http://cachefile.net/scripts/using/
The blog page that explains using.js is here: http://www.jondavis.net/blog/post/2008/04/Javascript-Introducing-Using-(js).aspx
This is a quick and dirty test of using.js. The using.js (10kb) script allows you specify a dependency script with its source URL for a particular feature so that it can be late-loaded, but it will not re-load the source twice. There is no dependency upon other script libraries like jQuery to get started with using.js.
The callback function will try to wait a bit for the referenced script
to load. The callback is truly synchronous (no wait) or the delay is set using
using.wait=[milliseconds];. You can reference
scripts on different domains by setting the global using.wait
property, or by declaring the URIs as external URIs by passing true
and/or an optional post-load milliseconds parameter before each URL, i.e.
using.register(true, 750, 'http://cachefile.net/scripts/jquery/1.2.3/jquery-1.2.3.js');.
The URL parameter in using.register()can take several URLs, not just one, as additional (third, fourth, ..) parameters to the using.register() function.
You do not need a callback function when calling using() if you just want to make sure the referenced script is loaded. using('jquery'); works fine as long as it has been pre-registered.
The big advantage of using.js is that you can manage one source script that does nothing but register a big list of script files by name, then in a larger web client app you can reference using.js and the registrations script and then have all you need for your app.
Test: Click on the buttons below more than once: