JSPM

load-jscript

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q25752F
  • License ISC

Module for script loader for the browser using the script tags

Package Exports

  • load-jscript

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 (load-jscript) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

load-jscript

Promise based script loader for the browser using script tags.

usage

install

$ npm install load-jscript

options

  • type: defaults to text/javascript.
  • async: defaults to true.
  • charset: defaults to utf-8.
  • id: no default value.

examples

// import module
import loadJScript from 'node_modules/load-jscript';
loadJScript.load(url|[urls], options)
    .then(callback)
    .catch(error) 
// single script
loadJScript.load('//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js').then(() => {
    console.log(_.VERSION);   
});

//multiple script
loadJScript.load([
    '//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js', 
    '//cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js']
    ).then(() => {
        console.log(_.VERSION);
        console.log(jQuery.fn.jquery);
    }
);