@ryanburnette/get-script-sync

1.0.4 • Public • Published

@ryanburnette/get-script-sync

npm version

Sometimes you need to get a script syncronously (blocking). My primary use case for this function is when I want to load a polyfill. I need to block my JavaScript until the polyfill is loaded.

var getScriptSync = require('@ryanburnette/get-script-sync');

if (window.NodeList && !NodeList.prototype.forEach) {
  getScriptSync('/javascripts/polyfills/nodelist-foreach.js');
  // => { request, element }
}

document.querySelectorAll('div').forEach(function (el) {
  el.classList.add('foo');
});

/@ryanburnette/get-script-sync/

    Package Sidebar

    Install

    npm i @ryanburnette/get-script-sync

    Weekly Downloads

    0

    Version

    1.0.4

    License

    ISC

    Unpacked Size

    1.89 kB

    Total Files

    3

    Last publish

    Collaborators

    • ryanburnette