Telling Firebug to Break as Soon as any Javascript is Executed

I’ve inherited a pile of code that’s doing unexpected things when I click on some <button> elements.

The page has a lot of Javascript, and it’s unclear what, if any, events have been setup on the button or its parent elements. I’m trying to find where execution starts so I can debug what’s going on.

  • Chrome and a TypeError due to SVGAnimatedString
  • How do I recognise if a variable's object type?
  • What is a good way to trace javascript execution as it happens (but skip jQuery)?
  • Find what javascript changes the DOM?
  • Rails: end of file reached
  • What are some good JS debugging tools?
  • Is there a way to have Firebug (or any Javascript debugger) break whenever any javascript code is executed? Maybe someway to setup a break point on each line programmatically? Or is there some other way to find out which event the button is responding to (page users boh Prototype, jQuery, and some custom Javascript. I know.)

  • Chrome Developer Tools, using inspection functions inside script tags
  • Get stacktrace for Ember Application in in production mode
  • Disable script editing in chrome developer tools
  • Browser Independent JavaScript debugger?
  • Pausing code execution in chrome from within JS. Possible?
  • How can I show a list of every thread running spawned by setTimeout/setInterval
  • 5 Solutions collect form web for “Telling Firebug to Break as Soon as any Javascript is Executed”

    Just press Pause button on the firebug panel (on the left-top corner of it, two yellow vertical lines, when Script tab selected) – and it will stops at first JS string.

    But it will stop JS executing really at ANY event – so if you have a button which catches mouse move and mouse click – i will not be able to stop on mouse click, since script will be stopped at mouse move each time you try to move mouse over this button. I suggest you just to insert alert()’s in the suspicious places – after some iterations you will found exactly string you need (where error occurs).

    Close the Internet browser and open it again. “Break on next” will start working again. Otherwise Firebug simply ignores this option after a while, and doesn´t break but run javascripts for all events without warning you.

    I found a bookmarklet that will list all bound events in your page.

    This kind be useful if you don’t know what events are bound by third-party code.

    If you want to see what events are set up on the page, you might also try Eventbug.

    If this is a generic debugging problem you can use the Web Inspector in Safari / Chrome. An added bonus is that you can throw the following statement into your JavaScript code to pull up the debugger:

    debugger; // Will trigger the debugger

    Otherwise you can set breakpoints, conditional breakpoints, pause on the next execution, and all the usual tricks. Some nice videos are available here.

    In response to the alert suggestion before. I would seriously recommend using console.log or console.dir if you have access to a debugger. You will get more information without blocking your script’s execution. Also, don’t forget that that console.log can take multiple parameters so you can nicely print out data, you don’t have to constrain yourself to a single string like alert.