views:

123

answers:

3

Hello,

I could never view a script correctly in Firebug,every one of them is displayed in one line.Like shown on the image below:

How do I view it correctly so I could debug it?

Thank you in advance!

+3  A: 

This script has been minified by removing all extraneous whitespace.

You cannot easily debug such scripts.

Scripts that you write yourself and that are not minified or compressed will appear on normally on multiple lines and can be debugged.

SLaks
Minifying (as noted in Umair's answer) also often changes variable names to be as short as possible (generally a single character) to save even more bytes.
Cameron
A: 

Script writers minify and often change variable names to difficult alphanumeric names, basically wanting the script to be least human readable so that no one copies their code/logic, as one can easily do that using firebug and similar stuff. such scripts can be a real pain to debug and there are very few chances that you will be able to understand this one. All the best with the task anyhow.

have you tried debugging it anyhow by having a breakpoint on this only available line ?

Umair
Minifying is also useful for reducing the download size of the JavaScript, thus making the page load faster.
aem
yeah correct the basic aim foe minification and merging scripts into one is lower page load times, i didn't mention that here in details just because the issue was related to debugging a minified script. Thanks for mentioning it too
Umair
A: 

For your own scripts, simply call:

console.log(someObject);

I usually hang around the "Console" tab, and see which errors or logged items come in, or use the console itself to type in code I want to run.

I never use the "Script" tab.

If you just want to view the code nicely, use a beautifier:jsbeautifier.org

Avindra Goolcharan
Thank you! Just what I was searching for.
John
You're kidding, right? The scripts tab is by far the most useful firebug tab. You can step in and debug your code, set watches, inspect variables, etc. Basically it lets you see your code, living and breathing; and you can modify that code on the fly to test assumptions about how you think it is supposed to work. I'm sorry, but to just blow all of that off and say console.log is good enough... madness!
Justin Ethier
Debugging using the Console tab and the DOM Inspector work fine enough for me, with the least glitches. I don't use "Script" because I remember I had far too many problems with it. Maybe it's better now?
Avindra Goolcharan