Created
November 25, 2016 07:07
-
-
Save z4none/fea905d6c1450f4e080d97a0739b2de1 to your computer and use it in GitHub Desktop.
load script
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 loadScript(url, onLoaded) { | |
| var loaded = false; | |
| var scriptTag = document.createElement('script'); | |
| scriptTag.src = url; | |
| scriptTag.onload = scriptTag.onreadystatechange = function(){ | |
| if(!loaded && onLoaded) { | |
| loaded = true; | |
| onLoaded(); | |
| scriptTag.onload = scriptTag.onreadystatechange = null; | |
| } | |
| } | |
| document.head.appendChild(scriptTag); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment