Skip to content

Instantly share code, notes, and snippets.

@jasisk
Created December 1, 2010 16:44
Show Gist options
  • Save jasisk/723770 to your computer and use it in GitHub Desktop.
Save jasisk/723770 to your computer and use it in GitHub Desktop.
Loads Firebug Lite (if necessary) and jQuery (if necessary)
(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