Pausing/Breaking execution in javascript for debugging, but only for certain javascript files

Do any browsers support pausing execution / stepping through code, but only for certain files or regions? I'm using jQuery and several other libraries, and I'm not interested in stepping through their code in 99% of cases, as it is my code that is wrong. All my code is in my script file, other libraries are included separately.

If I use the pause button, I tend to find that I am very quickly taken to some part of jquery with code I don't understand or need to understand. If I click the step into button a lot, I sometimes get taken to a point in my script, sometimes not.

I could manually click every single line of my code to add a breakpoint, but this would be extremely tedious, and I couldn't un-pause execution easily. If there is a browser that lets you select multiple lines and add breakpoints to all of them in one click, that would be a great alternative, though.

Answers:

Answer

There are some new features in the Chrome developer tools that can help you get a good entry point into a new code base. Event listener breakpoints will let you pause execution at a given event handler:

Answer

Things have changed since I asked the question 5 years ago. Chrome (and possibly other browsers) have an option "Blackbox script". If you find yourself paused inside a library, e.g. jQuery, right click, choose "Blackbox script" and you will automatically skip over all lines in that file when you are stepping through the code in future.

Answer

This is what step in/over/out is for. If the program is stopped for debugging, and you're stepping through and see that you're about to descend into a jQuery function (or anything else you want to skip over) you click "step over". If you got into something which you want to get right back out of, you click "step out".

Simply set the breakpoint where you want to begin debugging, and use the step functions from there to control what you're stopping to take a look at.

Answer

Put the break points in the desired javascript files and where you want to inspect your code! Press this will let you skip the jumping to other files and you will be able to continue in the same JS file

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.