Last active
January 11, 2017 20:07
-
-
Save iansinnott/3a026d182fef4cbb32a97bbd043ef202 to your computer and use it in GitHub Desktop.
Inject common scripts into the browser
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
((global) => { | |
var dict = { | |
ramda: '//cdnjs.cloudflare.com/ajax/libs/ramda/0.23.0/ramda.min.js', | |
rxjs: 'https://unpkg.com/@reactivex/rxjs/dist/global/Rx.js', | |
'lodash/fp': 'https://cdn.jsdelivr.net/g/lodash@4(lodash.min.js+lodash.fp.min.js', // Exposed as `_` | |
}; | |
// Returns the script tag | |
global.inject = (src) => { | |
var script = document.createElement('script'); | |
script.src = dict[src] || src; // Can manually inject any URL if its not found in dict | |
return document.body.appendChild(script); | |
}; | |
})(window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment