Hacker News new | past | comments | ask | show | jobs | submit login

>>setTimeout(function() { debugger; }, 5000);

This is clever; after all, the only way to beat the recursive turtle stack of chrome debuggers debugging themselves is with the debugger statement.

sam.pl, of the infamous myspace Sammy worm, used debugging gotcha's to prevent visitors from de-mystifying his obfuscated html homepage.




That's one of my most used bookmarklets: https://darekkay.com/blog/debugging-dynamic-content/


You can just hit F8 and the debugger will pause at the next instruction. Works in both Chrome/FF.


F8 first causes focus to be lost from the document body. Just tested in Chrome.


Neither the bookmarklet or F8 is ideal if you want to retain focus and any other state that you may effect by going and clicking or pressing a key.


Woah, “Emulate a focused page” is a great tip, too.


This is what happens when websites prevent an open Console/DevTools side panel. They basically have a main loop running, inserting a debugger; statement in various places where they're annoying, and they do that at 30FPS / 32ms so that the DevTools become useless because there's no way to "ignore" debugger statements.


Why would this be a problem? I have a debugger. If you conveniently invoke it for me I can simply delete the offending code.

Also both Chrome and Firefox have a "disable breakpoints" button that would instantly defeat this issue.


This button was added to specifically combat that, and even then it means you can't use breakpoints at all. IMO the missing link is a way to specifically ignore a single debugger call.


TFA has instructions on adding conditional breakpoint with 'false' inside. Wouldn't this work?


Yes, this will work. Sometimes you do it to yourself and you want to ignore the line.


The debugger lets you edit the code in the VM, so if there's a debugger call you don't want you can simply delete it and continue and it'll not show up again until you refresh


Another way to do this, if you don't want to wait 5 seconds, is just to use the "pause script execution" shortcut, which is cmd-\. It'll freeze the page on whatever line of JS was currently executing, and then you can inspect the problematic element like normal.


Browser makers: please ignore 'debugger' statements by default with an opt-in in the dev tools. Almost all legitimate uses of the debugger statement can be replaced with a simple breakpoint if you're working on the code.


Wait, that's it? This is too simple to be so good.


Nice, I never knew this trick existed




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: