I have a random internet page opened in my Chrome. I'm opening it with enabled javascript as I need some scripts to be executed.
Than from some moment I want to stop script execution, so no any timers or event handlers should be run. Of couse using an infinite loop is not ok as I want the page to be responsive.
How can I achive that?
Following code partially does what I need
document.body.outerHTML = document.body.outerHTML
for(t=setTimeout(()=>{}); t; --t) clearTimeout(t)
but:
document
and ajax callbacks will surviveAlso I hope there is some way to do it via devtools without actually interacting with page's code.
PS: If I need to use other browser, that's ok.
You can enable/disable JavaScript on the page at any point using the command menu in DevTools. You can access this menu by using Cmd+Shift+P (Mac) or Ctrl+Shift+P (Windows/Linux).
Start typing Disable JavaScript
and hit Enter to disable script execution.
In the following example, I ran an asynchronous timer to log an incremental count every 500ms. Upon disabling JavaScript, the execution was paused and nothing else logged to the console.
I later re-enabled JavaScript by typing 'Enable JavaScript` and hitting Enter. Upon doing this, the execution continued and the timer continued where it left off.
Note: Any synchronous code still running when you try to disable JavaScript won't be killed. It will finish and then further execution will be disabled.
Adding to Gideon Pyzer:
Shift-Ctrl-I
- wait for devTools to open,
then Shift-Ctrl-P
- if you don't wait: print dialog will open...
then -see Gideon Pyzer's answer-.
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