Remote loading API of JavaScript library
Powered by Google App Engine
How JsLoad Works
JsLoad is simple API.
Your site can import great JavaScript library from Google server.
And you do not need to mind dependence of the library.
JsLoad load dependencies of any version of the library automatically.
For example, in the case of Lightbox, JsLoad works as follows.
How to Use
Initialize
Add initialization script of JsLoad in the header element of HTML.
<script src="http://jsload.net/init"></script>
Load a library
Call JsLoad().
The first argument is the keyword of the library.
The second argument is your prefered version. If you omitted a version the latest stable version is used.
<script type="text/javascript">
JsLoad("jquery", "1.2.6");
JsLoad("scriptaculous"); // latest stable version
</script>
If you load many libraries, you can use JsLoad.set().
The performance improves, because a request to Google server is transmitted in a mass.
<script type="text/javascript">
JsLoad.set("jquery", "1.2.6");
JsLoad.set("scriptaculous");
JsLoad(); // "jquery" and "scriptaculous" are loaded
</script>
Simple style
You can also use more simple style.
Write one request in one line.
A whitespace is ignored, you can use indentation and line break for your good style.
<script src="http://jsload.net/init"> jquery (1.2.6) scriptaculous </script>
Options
Compression
You can request a compression level of JavaScript file.
If a compressed file is not distributed officially,
it is compressed in YUI Compressor or JSMin.
There are 3 compression levels.
| u | : uncompressed |
|---|---|
| m | : minified (default) |
| p | : packed |
<script type="text/javascript">
JsLoad("jquery", "1.2.6", "u"); // uncompressed
JsLoad("scriptaculous", "p"); // packed
</script>
<script src="http://jsload.net/init"> jquery (1.2.6) -u scriptaculous -p </script>
Behavior
The behavior of the default of JsLoad is automatic dependency loading, and if the library has already been loaded, it will not be loaded again. If you want to control this behavior, you can change it.
| o | : load only a library |
|---|---|
| f | : load only a library forcibly again |
| d | : load a library with dependencies (default) |
<script type="text/javascript">
JsLoad("scriptaculous", "1.8.0");
// "prototype" and "scriptaculous" are loaded
JsLoad("lightbox", "2.03", "o");
// only "lightbox" is loaded
JsLoad("prototype", "1.6.0.2");
// "prototype" is not loaded again
JsLoad("prototype", "1.6.0.2", "f");
// "prototype" is loaded forcibly
</script>
<script src="http://jsload.net/init"> scriptaculous (1.8.0) lightbox (2.03) -o prototype (1.6.0.2) prototype (1.6.0.2) -f </script>
Bridge to CDN (Contents Delivery Network)
When CDN of the library has the same resources,
you can use this network for a performance.
Popular CDN will be supported.
Yahoo! CDN (YUI),
AOL CDN (Dojo)
and Google AJAX Libraries API (jQuery, MooTools, Prototype...)
| c | : load a library from CDN |
|---|
<script type="text/javascript">
JsLoad("jquery", "1.2.6", "c"); // load library from CDN
</script>
<script src="http://jsload.net/init"> jquery (1.2.6) -c </script>
If CDN does not have the version and the compression level that you request, JsLoad loads own library.
<script type="text/javascript">
JsLoad("jquery", "1.0", "c");
// version "1.0" are not hosted on CDN
// load library from JsLoad
</script>
Builder
If you are expert of the library, you can build the library which you want.
| b | : load a library builder |
|---|
<script type="text/javascript">
JsLoad("scriptaculous", "b");
// only "prototype" is loaded
// "scriptaculous" is not yet loaded
JsLoad("lightbox", "2.04", "b");
// "lightbox" is not yet loaded
</script>
<script type="text/javascript">
JsLoad.scriptaculous.build("builder", "effects");
// build "scriptaculous", Builder and Effects are loaded
JsLoad.lightbox.build("lightbox", "theme");
// build "lightbox", Core and Theme are loaded
</script>
<script src="http://jsload.net/init"> scriptaculous -b; + builder, effects lightbox (2.04) -b + lightbox, theme </script>
Mix an option?
Of course, you can do it!
<script type="text/javascript">
JsLoad("jquery", "1.2.6", "uc");
JsLoad("scriptaculous", "1.8.0", "pb");
</script>
<script type="text/javascript">
JsLoad.prototype.scriptaculous.build("builder", "effects");
JsLoad("lightbox", "2.03", "po");
</script>
<script src="http://jsload.net/init"> jquery (1.2.6) -uc scriptaculous (1.8.0) -pb + builder, effects lightbox (2.03) -po </script>
Recent Changes
-
Prototype (1.6.0.3)
Added a new version.
Date: 2008-10-03 -
JSDeferred (0.2.2)
Added a new version.
Date: 2008-10-03 -
Taffy DB (1.6.1)
Added a new version.
Date: 2008-10-03 -
Taffy DB (1.6)
Added a new version.
Date: 2008-10-03 -
JavaScript-XPath (0.1.11)
Added a new version.
Date: 2008-07-01