Created
January 29, 2009 04:51
-
-
Save sandro/54387 to your computer and use it in GitHub Desktop.
load jquery with callback
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 load_jquery(){ | |
var s=document.createElement('script'); | |
s.type='text/javascript'; | |
s.src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js'; | |
var head = document.getElementsByTagName("head")[0]; | |
var done = false; | |
s.onload = s.onreadystatechange = function(){ | |
if ( !done && (!this.readyState || | |
this.readyState == "loaded" || this.readyState == "complete") ) { | |
done = true; | |
head.removeChild(s); | |
your_jquery_loaded_callback_function(); | |
} | |
}; | |
head.appendChild(s); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment