Package Exports
- get-js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (get-js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Get JS
A lightweight Promise based package to load scripts dynamically in the browser.
Installation
$ npm install get-js --save
You'll also need a Promise polyfill for older browsers.
$ npm install es6-promise
Usage
Include the package using common js require()
:
var get = require('get-js');
Or, using <script>
tags:
<script type="text/javascript" src="/path/to/get-js/dist/get.min.js"></script>
Here you go:
// Load single script
get('https://code.jquery.com/jquery-2.2.3.min.js').then(function() {
console.log('do something');
});
// Load multiple scripts, without changing the order
get([
'/js/abc.js',
'/js/xyz.js'
]).then(function() {
console.log('do something now');
}).catch(function() {
console.log('error');
});