Skip to content

Instantly share code, notes, and snippets.

@sergiogarciadev
Last active June 12, 2017 14:58
Show Gist options
  • Save sergiogarciadev/749af1faa934aa40343d654c1cb3980e to your computer and use it in GitHub Desktop.
Save sergiogarciadev/749af1faa934aa40343d654c1cb3980e to your computer and use it in GitHub Desktop.
Bookmark to easily load JS modules from unpkg
// Make a bookmark with:
// javascript:function load(e,n){return System["import"](e).then(function(o){return console.log("Module "+e+" loaded."),window[n?n:e]=o,o})}var s=document.createElement("script");s.setAttribute("src","https://unpkg.com/getlibs"),document.body.appendChild(s),console.log("JS Loader instaled!\n\nload(<module>, <alias>)\n\nUse:\n > load('jquery', '$')");
//
// Unminified JS
var s = document.createElement('script');
s.setAttribute('src', 'https://unpkg.com/getlibs');
document.body.appendChild(s);
function load(moduleName, alias) {
return System.import(moduleName).then(function (module) {
console.log('Module ' + moduleName + ' loaded.');
window[alias ? alias : moduleName] = module;
return module;
});
};
console.log("JS Loader instaled!\n\nload(<module>, <alias>)\n\nUse:\n > load('jquery', '$')");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment