Skip to content

Instantly share code, notes, and snippets.

@shanewholloway
Created August 29, 2018 21:48
Show Gist options
  • Save shanewholloway/5113ff46c0a79718653410fc0c0ef9f2 to your computer and use it in GitHub Desktop.
Save shanewholloway/5113ff46c0a79718653410fc0c0ef9f2 to your computer and use it in GitHub Desktop.
Tiny dynamic script resource loader
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