Skip to content
Dynamically loading external JavaScript and CSS files
JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
.gitignore
ChangeLog
LICENSE
README.md
bower.json feature(bower) moduleType: add node
load.js
load.min.js feature(load) update min version
package.json

README.md

Load.js

Dynamically loading external JavaScript and CSS files

Install

bower install load

How use?

Create html page with js connected.

<script src="load.min.js"></script>

Than try one of this:

load.js('jquery.js', function(error) {
    /* you could use jquery functions here */
});

load.css('menu.css', function(error) {
    /* load menu css and then do some magic */
});

/* recognition file type by extension */
load('css-or-.js', function(error, event) {
    console.log(error || event);
});

load('template/footer.html', function(error, footer) {
    console.log(error || footer);
});

load.json('config.json', function(error, config) {
    console.log(error || config);
});

load.ajax('template/header.html', function(error, header) {
    console.log(error || header);
});

/* load one-by-one */
load.series([
    'jquery.js',
    'jq-console.js',
], function(error) {
});

/* load all together and call callback */
load.parallel([
    'menu.css',
    'menu.js',
], function(error) {
});

License

MIT

Something went wrong with that request. Please try again.