JSPM

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

Simple promise-based script loader for modern browsers

Package Exports

  • promisescript

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

Readme

Promise Script

A promise for loading client-side scripts asynchronously.

Install

npm install promisescript

[Contrived] Example

var promisescript = require('promisescript');

function loadFacebook() {
  return promisescript('https://connect.facebook.net/en_US/all.js').then(function() {
    appId: 'YOUR_APP_ID',
    channelUrl: '//github.com/terinjokes/promisescript'
  });
}

loadFacebook.then(function() {
  FB.XFBML.parse();
});

Notes

  1. If you make multiple requests to the same URL, it will only be fetched once and the same promise will be returned.
  2. The promises returned by this module are pretty barebone, and you may wish to coerce it into a promise of your favorite library.

License

MIT