get-script-sync
@ryanburnette/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');
});