cdn-buddy
v0.5.1
Published
Load JS and CSS from a source of your choosing.
Downloads
20
Readme
cdn-buddy
Browser friendly, promise based JS and CSS loader.
It's all global
cdn-buddy will live in a variable you may declare:
__CDN_BUDDY_NAMESPACE = 'myBuddy' // defaults to cdnBuddy
In your build pipeline
__CDN_BUDDY_NAMESPACE = 'cdn'
require('cdn-buddy')
cdn.setConfig({
"baseUrl" : "https://unpkg.com/",
"paths": {
"jquery" : "[email protected]/dist/jquery.min.js"
}
})
(async function() {
await cdn.require(['jquery', '[email protected]/dist/vue.js'])
await cdn.require(['jquery-ui'])
// Your dependent code goes here
})()
In the Browser
<script src="cdn-buddy/dist/cdn-buddy.min.js"></script>
<script>
cdnBuddy.require(['jquery', '[email protected]/dist/vue.js']).then(function() {
$('body').css('backgroundColor', 'lime')
})
</script>