Last active
January 3, 2018 12:33
-
-
Save archangel-irk/c04fa175d67510acabb228f78b05f42d to your computer and use it in GitHub Desktop.
loadScript (Promise)
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
function loadScript(src) { | |
return new Promise(function(resolve, reject) { | |
const script = document.createElement('script'); | |
script.src = src; | |
script.onload = resolve; | |
script.onerror = reject; | |
document.head.appendChild(script); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment