var jQueryScriptOutputted = false;
function initJQuery() {
//if the jQuery object isn't available
if (typeof(jQuery) == 'undefined') {
if (! jQueryScriptOutputted) {
//only output the script once..
jQueryScriptOutputted = true;
//output the script (load it from google api)
document.write("<scr" + "ipt type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></scr" + "ipt>");
}
setTimeout("initJQuery()", 50);
} else {
$(function() {
//do anything that needs to be done on document.ready
});
}
}
Psst! Create a DigitalOcean account and get $200 in free credit for cloud-based hosting and services.
It seems like you haven’t escaped the strings in the document.write("scr"+...), this will make JS engine thought that you enclosed the quotes too soon, causing the JS engine to throw an error
so which one would be best to use, for speed, etc?
There is no any difference in speed loading
It seems like you haven’t escaped the strings in the
document.write("scr"+...)
, this will make JS engine thought that you enclosed the quotes too soon, causing the JS engine to throw an error