Debugging frontend js with chrome dev tools



  • What is the ideal way to approach debugging scripts that run on page load?

    Javascript loaded from widget areas always runs in an individual VM with no file name reference making breakpoints that are meant to stop scripts that run on page load meaningless, because on every refresh chrome seems to think it's a new resource and gets rid of all the breakpoints.

    For some reason I get the same behavior with nodebb.min.js. The breakpoints are all lost on refresh, although the resource name is the same every time (nodeb.min.js?a-long-id-like-param)

    The only way I can think of is to cause whatever is meant to run on a page load to run on some sort of a specific event that is triggered after I got a chance to set the breakpoints. Or simply flood the code with console.logs


  • Global Moderator

    @Qwertyzw you could put a debugger; statement where you want it to break.


Log in to reply
 

Looks like your connection to NodeBB was lost, please wait while we try to reconnect.