Chrome JavaScript Debugging - how to save break points between page refresh or break via code?

前端 未结 8 880
情深已故
情深已故 2021-01-31 06:46

When using Chrome and it\'s JavaScript debugger, every time I reload my page / scripts, my breakpoints are lost and I have to go find the script file in the pop-up, find the lin

8条回答
  •  名媛妹妹
    2021-01-31 07:25

    You can put a

    debugger;
    

    to break in most of the JavaScript environments. They will persist for sure. It's good to have a minifier that rids the debugger and console.log calls for the production environment, if you are using these.

    In the recent versions of Chrome browser, there is a "Preserve Log" option on the top of the console panel, next to the filters. In the older versions, right clicking on the empty console window will bring that option ("Preserve log upon navigation"). It's handy when you don't have console.log statements or hard-coded debugger calls.

    update: I found a tool on github, called chimney, which takes a file and removes all the console.log calls. it gives a good idea about how to remove debugger calls.

提交回复
热议问题