JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 294
  • Score
    100M100P100Q79556F
  • License MIT

A Promise based package to load scripts dynamically

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

NPM Version NPM Downloads Code Climate

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