load-scripts
v2.0.0
Published
Dynamic scripts loading for modern browsers.
Downloads
2,386
Maintainers
Readme
load-scripts
Dynamic scripts loading for modern browsers.
Main files
dist/
├── load-scripts.js (UMD, default)
├── load-scripts.min.js (UMD, compressed)
├── load-scripts.esm.js (ECMAScript Module)
├── load-scripts.esm.min.js (ECMAScript Module, compressed)
└── load-scripts.d.ts (TypeScript Declaration File)
Getting started
Installation
npm install load-scripts
In browser:
<script src="/path/to/load-scripts.js"></script>
Usage
Syntax
loadScripts(script1, script2, ..., scriptN)
.then(() => {})
.catch((err) => {})
.finally(() => {});
Example
import loadScripts from 'load-scripts';
loadScripts('foo.js').then(() => {
console.log(window.Foo);
});
loadScripts('foo.js', 'bar.js').then(() => {
console.log(window.Foo, window.Bar);
});
In browser:
<script>
loadScripts('foo.js').then(() => {
console.log(window.Foo);
});
</script>
Browser support
- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Opera (latest)
- Edge (latest)
- Internet Explorer 10+ (requires a
Promise
polyfill as es6-promise)
Versioning
Maintained under the Semantic Versioning guidelines.