开发者

why does firebug debugging sometimes work and sometimes not?

I want to debug a javascript file that is embedded in the HEAD element.

I navigate to the site, see the code, and make a breakpoint:

why does firebug debugging sometimes work and sometimes not?

(source: deviantsart.com)

But when I click on Reload, the script disappears and it doesn't stop at the breakpoint:

why does firebug debugging sometimes work and sometimes not?

(source: deviantsart.com)

Debugging was working earlier so I know it works in general. What开发者_如何转开发 do I have to do so that Firebug always debugs my script?


I've noticed this behaviour before as well. It seems that it can happen if you refresh the page while the debugger is running (i.e. after you've hit your breakpoint and are stepping through code). This is far from conclusive, just something I've casually observed over time.

Also, I try to avoid having multiple tabs open with firebug active, as it seems to get confused.

Edit: just thought I'd add that I've seen this manifest itself in a few different ways:

  • the external script file does not appear at all in the scripts panel.

  • the external script file appears but firebug doesn't "see" it. You know this has happened because the line numbers beside the code where a breakpoint can be set won't be highlighted (used to be green but now appear to be just a darker shade than other lines). I've seen this happen with inline javascript on a HTML page (horrors!) as well.

  • the external script file is there, but you can only see a single screen full of code. Where "screen full" is the firebug panel viewport.


shut down firefox and then restart. sometimes firebug gets confused. also make sure you have the latest version.


You need activate the script tab

why does firebug debugging sometimes work and sometimes not?


I'm not sure that having a <script> inside <head> (as opposed to, inside <body>) is actually legal HTML. If it's not, as I suspect, you can't fault Firebug for not supporting it well...!-)


The bugs in script processing that I know about are 1) jquery dynamic loading of scripts fails, 2) new Function() cannot be seen, 3) some kinds of document.write() cannot be seen.

Firebug processes script files in series with Firefox. This means that Firebug must be active when the page loads and it means that any exception in the path will cause the files to be mis-processed. If you opened firebug before loading and you still see problems, then the most likely fix is to install Firebug in a new Firefox profile. This causes you to get a completely fresh set of default options and you run Firebug without other extensions. As you re-add other extensions, look for problems in seeing scripts: then maybe you will discover what extension is interfering with the code path for processing scripts. I know this is a pain in the neck, but so is JS debugging without source ;-). We are working on testing with more Firebug and Firefox extensions installed to try to reduce these problems.


In our case it was the bundling of JS files.

It is not only FireFox, it is same for Chrome.

We moved the file out of the bundle and put it on the page where it needed to be referenced and it started working like charm.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜