Script Loader
Asynchronously load Javascript from HTML.
Usage
1. Create an element that requires its own Javascript file
<section class="js-module" data-script-src="/js/cool-module.js">
<h1>This is a module</h1>
<p>It does cool things that requires a large Javascript file.</p>
<p>I care about performance, so I am only going to load said Javascript file as needed.</p>
</section>
2. Load the scriptLoader before the closing body tag of your document
<script src="/js/lib/scriptLoader.js"></script>
<script>
scriptLoader('js-module'); // Pick any class name you'd like.
</script>
</body>
You can also use the scriptLoader in a module system like Browserify:
var scriptLoader = require('./path/to/scriptLoader.js');
scriptLoader('js-module');