views:

84

answers:

4

I'm using django-compress to shrink my javascript files. However, I am now having trouble debugging through it because everything is squished. I believe stackoverflow use some kind of js compression too. How do you go about to debug through your javascript on the live site or on your dev machine with the code well formatted? Firebug has all the code in one line which makes it hard to dig through.

+9  A: 

The simple answer is you don't debug through a compressed file - you use an uncompressed version for development.

Greg
Also, if you are using a mix of code you have written as well as code from outside libraries, most libraries also provide uncompressed versions of their code that is helpful for debugging.
Josh
A: 

Debug before compressing. Compressing and then debugging is way over the line for premature optimization. Just as you would finish developing a C++ program before removing the comments and rename all the variables to be cryptic (that almost no one does this demonstrates just how silly it is).

wallyk
A: 

If you are using Google Closure, then there is a plugin that allows you access the unminified version of the code. See the documentation on the Inspector and the source mapping feature.

Jeff Foster
A: 

Some suggestions:

  • Don't compress until you deploy to production
  • Reload your source code after the compress code; it will write over the compressed code
  • When it's worth the investment, I take compressed code and manually uncompress it
Upper Stage