Created
August 29, 2018 21:48
-
-
Save shanewholloway/5113ff46c0a79718653410fc0c0ef9f2 to your computer and use it in GitHub Desktop.
Tiny dynamic script resource loader
This file contains hidden or 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
const tiny_load = src => | |
new Promise((onload, onerror) => | |
document.head.appendChild( | |
Object.assign( | |
document.createElement('script'), | |
{src, onload, onerror}, | |
src.startsWith('http') | |
? {crossorigin: true} | |
: null ) )) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment