Created
October 5, 2016 06:28
-
-
Save mohayonao/f6995fb138f02ccd6b4ebf13f46e54c6 to your computer and use it in GitHub Desktop.
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
function importScript(src) { | |
return new Promise((resolve, reject) => { | |
const script = document.createElement("script"); | |
script.async = 1; | |
script.type = "text/javascript"; | |
script.src = src; | |
script.onerror = reject; | |
script.onload = () => { | |
document.body.removeChild(script); | |
resolve(); | |
}; | |
document.body.appendChild(script); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment