1252748
1252748

Reputation: 15372

make Chrome script breakpoints persistant between page (re-)loads

I have scripts that run when the document loads. But to see changes I've made to the page, I must reload it, and this clears out all the breakpoints I've set in my script. Is there anyway to make those breakpoints persistant from pageload-to-pageload? It seems like Chrome used to do this automatically, but doesn't anymore. Thanks

Upvotes: 0

Views: 136

Answers (2)

inkdeep
inkdeep

Reputation: 1127

In the sources tab of Chrome developer tools you should be able to click a line number and get a blue arrow. This will set a breakpoint that will persist between page loads.

Upvotes: 0

BigMike
BigMike

Reputation: 6873

add the instruction

if (my_dbg != undefined) {
    debugger;
}

to your scripts. If you want to enable breaks, then somewhere add a:

var my_dbg = true;

Not too elegant, but should resolve your issue.

For exaple:

$(document).ready(function(){
   $('#submit_me').click(function () {
      if (my_dbg != undefined) {
        debugger;
      }
   });
   // do other important things...
   if (my_dbg != undefined) {
        debugger;
    }
   // moar important things follow, need to debug
});

Before loading the page again, popup js console and type

var my_dbg = true;

then hit reload. Should work just fine.

Upvotes: 1

Related Questions