Created
July 16, 2017 13:47
-
-
Save vanaf1979/bb57f6d6bebfdd2f9a426381a360ac8d to your computer and use it in GitHub Desktop.
Run code after a dependancy has been injected into the page
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 depend( url , callback ) | |
{ | |
var script = document.createElement( 'script' ); | |
var scripts = document.getElementsByTagName( 'script' )[0]; | |
script.async = true; | |
script.onload = function() | |
{ | |
script.onload = null; | |
callback(); | |
} | |
script.src = url; | |
( document.getElementsByTagName( "head" )[ 0 ] ).appendChild( script ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment