JavaScript Include
JavaScript Include is a simple script for including scripts on the fly. It relies on XMLHttpRequest
and eval()
to load scripts as soon as they’re requested.
JavaScript Include uses a very simple module pattern to package scripts as self-contained modules. It includes a function called namespace()
, which is inspired by the YUI namespace function. JavaScript Include itself is written in its module pattern, and there is also an example provided at src/example.js
.
JavaScript Include always evaluates scripts in an anonymous scope, so the module must use either the namespace()
function or make a window
reference to make functions visible to other scripts.
Organization
The source code for JavaScript Include is located in src/js/include.js
. A minified version is also supplied.
An example module is located at src/example.js
. You can ensure that it works by opening src/example.html
.
A copy of the GNU General Public License, under which this script is distributed, is located in COPYING
.
Compatibility
Tested with most browsers I can easily get my hands on:
Browser | Platform | Result |
---|---|---|
Safari 3 | Mac OS X | Success |
Firefox 3 | Mac OS X | Success |
Opera 9.6 | Mac OS X | Success |
Camino 1.6 | Mac OS X | Success |
Google Chrome | Windows XP | Success |
Firefox 3 | Windows XP | Success |
Opera 9.6 | Windows XP | Success |
Internet Explorer 8 | Windows XP | Success |
Internet Explorer 7 | Windows XP | Success |
Internet Explorer 6 | Windows XP | Success |
Internet Explorer 5.5 | Windows XP | Success |
Copyright
Copyright © 2009 Andrew Noyes
This program is distributed under the terms of the GNU General Public License