mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-20 18:18:56 +00:00
63 lines
1 KiB
Markdown
63 lines
1 KiB
Markdown
# Load.js
|
|
|
|
Dynamically loading external JavaScript and CSS files
|
|
|
|
## Install
|
|
|
|
```
|
|
bower install load
|
|
```
|
|
|
|
## How use?
|
|
Create `html` page with `js` connected.
|
|
|
|
```html
|
|
<script src="load.min.js"></script>
|
|
```
|
|
|
|
Than try one of this:
|
|
|
|
```js
|
|
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() {
|
|
});
|
|
|
|
/* load all together and call callback */
|
|
load.parallel([
|
|
'menu.css',
|
|
'menu.js',
|
|
], function() {
|
|
});
|
|
```
|
|
|
|
## License
|
|
|
|
MIT
|