Skip to content

Instantly share code, notes, and snippets.

@TechNinjaWeb
Last active July 27, 2017 10:20
Show Gist options
  • Save TechNinjaWeb/a10ee28ecdac1794797f9dd58b3c2c28 to your computer and use it in GitHub Desktop.
Save TechNinjaWeb/a10ee28ecdac1794797f9dd58b3c2c28 to your computer and use it in GitHub Desktop.
Will take any array of cdn's and load them by pasting the code into the console.
/*************************************************
* Example Script Loader: will load any scripts
* from cdn by pasting this in the console.
*************************************************/
var scripts = loadScripts([
"https://code.jquery.com/jquery-3.2.1.min.js",
"https://cdnjs.cloudflare.com/ajax/libs/rxjs/4.0.6/rx.all.js",
"https://cdnjs.cloudflare.com/ajax/libs/parse/1.10.0/parse.js"
]);
function loadScript(url, loader){
var script = document.createElement('script');
script.onload = loader;
script.src = url;
document.getElementsByTagName('head')[0].appendChild(script);
return script
}
function loadScripts(scripts){ return scripts.map((script)=>{ return loadScript(script, null) }) }
function defaultObservableHandler(game){ observer.onNext(game) }
/*************************************************
* Example Style Loader: will load any stylesheet
* from cdn by pasting this in the console.
*************************************************/
var styles = loadStyles([
"https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.css"
]);
function loadStyle(url){
var link = document.createElement( "link" );
link.href = url;
link.type = "text/css";
link.rel = "stylesheet";
link.media = "screen,print";
document.getElementsByTagName( "head" )[0].appendChild( link );
return link;
}
function loadStyles(styles){ return styles.map((style)=>{ return loadStyle(style) }) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment