#include for JavaScript

Answering the cries of JavaScript newbies and experts alike.

If the #include script worked, this paragraph should be red.

Usage

Add the script include.js to your page. Then in the body of the same <script> element, add your #include-capable code:

<script src="include.js">
#include external.js
#include dependency.js
#include class.js

alert('This script will be executed after all other scripts have loaded!');
</script>

Limitations

#include doesn't work in external scripts. A future version may be able to—but only for locally hosted scripts. (Cross-domain scripts can't be preprocessed, and for that matter, #include shouldn't be allowed there anyway.)

In Internet Explorer, script loading isn't seamless (due to the alternate method used to hack around IE). You may notice a delay before the text switches to red.