Created
November 22, 2016 03:35
-
-
Save basarat/bca33d541b922de372d070e741df8616 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
/** | |
* Utility : Resolves when a script has been loaded | |
*/ | |
function include(url: string) { | |
return new Promise<{ script: HTMLScriptElement }>((resolve, reject) => { | |
var script = document.createElement('script'); | |
script.type = 'text/javascript'; | |
script.src = url; | |
script.onload = function() { | |
resolve({ script }); | |
}; | |
document.getElementsByTagName('head')[0].appendChild(script); | |
}); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment