So I'm working on a set of global javascript files for redball. I'll post more on this when I'm finished (hopefully including documentation and examples, but that might take me a while), but here's something I just whipped up that you might find useful.
I'm compressing all my javascript (so no extra spaces or comments) which means that debugging these things is going to be a pain. If you get an error on the live site and need to fix it, the debugging info you get out of your browser won't be that helpful in fixing things. On top of that, I don't want to have to edit a compressed file to debug it.
Previously, what I did was overwrote the compressed version with the non-compressed version to debug my stuff, but this is a pain if the code is on akami and you don't want to do a bunch of work to change that.
So I wrote up a little script that goes along with my dbug console wrapper for firebug (note the update comment below the post for the most recent code). Here's the function:
function dbugScripts(baseurl, libs){
if(window.location.href.indexOf("debug=true")>0){
for(i=0;i
");
}
return true;
}
return false;
}
Then, you go to your compressed libraries and you do this:
if(!dbugScripts("/the/location/of/my/scripts/",["script1.js","script2.js","etc"])){
...all my compressed javascript goes here...
}
So what's this do? If you put "debug=true" into the query string of the page you're viewing (and wish to debug), then all the dbug.log statments (again, see my dbug console wrapper function) will go to the console.log AND all your compressed javascript files will be ignored, with the document instead using the non-compressed versions. Voila, easy debugging.
Have fun.