Skip to content

Instantly share code, notes, and snippets.

@hcz
Last active September 22, 2018 13:11
Show Gist options
  • Select an option

  • Save hcz/4cfb35bcc3df7861f00db222b422c5ce to your computer and use it in GitHub Desktop.

Select an option

Save hcz/4cfb35bcc3df7861f00db222b422c5ce to your computer and use it in GitHub Desktop.
Adds scripts from CDN in browser console or via bookmarklet
/**
* Adds scripts on page without CORS to use additional scripts from CDN
* Creates scripts inside <head> tag
*
* @license MIT
* @copyright Sergei Osipov 2017
*/
((cdnList) => {
cdnList
.filter((cdn)=>{
return (typeof cdn === 'string' || cdn instanceof String) ? String(cdn) : false;
})
.forEach((cdn) => {
const _ = document.createElement('script');
_.src = cdn;
document.getElementsByTagName('head')[0].appendChild(_);
})
})([
// todo: Fix list here
'https://cdn.jsdelivr.net/npm/lodash@4.17.5/lodash.min.js',
'https://unpkg.com/react@16/umd/react.development.js',
'https://unpkg.com/react-dom@16/umd/react-dom.development.js'
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment