@ryanburnette/get-script-sync
v1.0.4
Published
Browser lib get getting an external script syncronously (blocking).
Downloads
4
Readme
@ryanburnette/get-script-sync
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');
});