0.3.0 • Published 9 years ago

html-script-loader v0.3.0

Weekly downloads
1
License
MIT
Repository
github
Last release
9 years ago

Script Loader Build Status

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');
0.4.0

9 years ago

0.3.0

9 years ago

0.2.0

9 years ago

0.1.0

9 years ago