I need code to use regular javascript to determine if jQuery is present, if not, download the jQuery file from Google or another website.
UPDATE Two working solutions (just copy and paste the working code here):
From Claudio Redi
window.jQuery || document.write("<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'>\x3C/script>")
From Rob Darwin
var jQueryScriptOutputted = false; function initJQuery() { if (typeof(jQuery) == 'undefined') { if (! jQueryScriptOutputted) { jQueryScriptOutputted = true; document.write("<scr" + "ipt type=\"text/javascript\" src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js\"></scr" + "ipt>"); } setTimeout("initJQuery()", 50); } } initJQuery();
source share