What is the equivalent of pressing Ctrl+C in console, for Chrome and Firefox? While implementing various algorithms I often write some buggy (while
) loop, in Javascript, that doesn't exit, makes the browser freeze. Reloading doesn't work, clicking little X for closing the tab doesn't do anything, and in a while (literally) I'm outta memory, system is swapping, and I'm leaving for a coffee break.
In Chrome, you can hit Shift+ESC
(or right-click the title bar and open the Chrome task manager) and kill the process associated with the hung tab. This will work in cases where closing the tab would not.
The caveat is, sometimes Chrome will streamline several tabs into one process, and this will kill all the tabs associated with the process.
Another approach you can take to avoid while
loops hanging the browser is to write code like this (you can take it out after testing):
var maxIterations = 100000;
while (foo) {
if (!maxIterations--) throw new Error('Max iterations hit, aborting.');
// do stuff
}
Right-click in Chrome's task manager and select the item on the bottom of the context menu to reveal a strange easter egg.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With