Created
June 15, 2018 22:58
-
-
Save mattbontrager/8fadc0cba57dacc6d3dea2405e29dbb3 to your computer and use it in GitHub Desktop.
Asynchronously load other JavaScript files.
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
const loadScript = src => { | |
return new Promise((resolve, reject) => { | |
const script = document.createElement('script'); | |
script.async = true; | |
script.src = src; | |
script.onload = resolve; | |
script.onerror = reject; | |
document.body.appendChild(script); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment