Last active
June 12, 2017 14:58
-
-
Save sergiogarciadev/749af1faa934aa40343d654c1cb3980e to your computer and use it in GitHub Desktop.
Bookmark to easily load JS modules from unpkg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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