Created
December 1, 2010 16:44
-
-
Save jasisk/723770 to your computer and use it in GitHub Desktop.
Loads Firebug Lite (if necessary) and jQuery (if necessary)
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(){ | |
if (typeof window.console === 'undefined'){ | |
//Load Firebug Lite | |
var firebug_Script = document.createElement('script'); | |
firebug_Script.setAttribute('src','https://getfirebug.com/firebug-lite.js#startOpened'); | |
document.body.appendChild(firebug_Script); | |
var tI = setInterval(function(){ | |
if(typeof window.console !== 'undefined'){ | |
console.info('Firebug Lite attached.'); | |
clearInterval(tI); | |
add_jQuery(); | |
} | |
},100); | |
}else{ | |
add_jQuery(); | |
} | |
function add_jQuery(opts){ | |
var _script=document.getElementsByTagName('SCRIPT'); | |
if ((typeof opts!='undefined'&&opts.jQOverride!==true)||typeof jQuery=='undefined'){ | |
for (var i = 0;i<_script.length;i++){ | |
if (/jquery\.(min\.)?js/.test(_script[i].src)) | |
console.warn('jQuery appears broken (check %s)',/[^/]+$/i.exec(_script[i].src)); | |
} | |
} | |
if (typeof jQuery=='undefined'){ | |
console.log('Attempting to load jQuery ...'); | |
var jQuery_Script = document.createElement('script'); | |
jQuery_Script.setAttribute('src','http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js'); | |
document.body.appendChild(jQuery_Script); | |
var tI = setInterval(function(){ | |
if(typeof jQuery!=='undefined'){ | |
console.info('jQuery (%o) attached.',jQuery); | |
clearInterval(tI); | |
}else{ | |
console.log('Waiting 100ms..'); | |
} | |
},100); | |
}else{ | |
console.info('jQuery (%o) already loaded.',jQuery); | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment