0

I am loading an HTML page in my browser from a web site. As far as I understand, the browser loads the page first, then starts executing the JavaScript code on it.

Question: How can I pause the JavaScript execution in Google Chrome as soon as the page is done loading, and then start it after, manually?

What I am trying to achieve is to load the page in a browser (any browser, but preferably Google Chrome), but edit the javascript code before it starts executing.

16
  • 1
    What do you mean by 'edit' the Javascript? Commented Mar 31, 2015 at 18:26
  • @dave I mean that I want to edit the javascript code on the page, before it starts executing Commented Mar 31, 2015 at 18:26
  • Are you talking about an evil post-load-javascript-manipulation or a basic timeout? Also, how would you "edit the javascript code" if, to check if the dom has been loaded, you probably are already using javascript..? Commented Mar 31, 2015 at 18:27
  • Are you trying to debug a page? Chrome allows you to set breakpoints and pause execution in the Developer Tools. Commented Mar 31, 2015 at 18:28
  • Your assumption isn't always true, but you could use the HTML body elements onload handler, to execute a script once the page loads. Also, Chrome has built-in developer tools to set breakpoints and debug the javascript. Commented Mar 31, 2015 at 18:29

2 Answers 2

1

Check out Debugging Javascript in Chrome. You can set breakpoints at the beginning of any JS file and then continue from there.

Debugging with breakpoints

A breakpoint is an intentional stopping or pausing place in a script. Use breakpoints in DevTools to debug JavaScript code, DOM updates, and network calls.

Click the line gutter to set a breakpoint for that line of code. A blue tag will indicate if a breakpoint has been set

Sign up to request clarification or add additional context in comments.

Comments

1

Well, in Google Chrome you can achieve this with the developer tools (and in most other popular browsers). Open them with F12 and set a breakpoint in your script under the "Sources" tab.

You can then edit and save (Ctrl-S) your script and press F8 to continue execution with the new code.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.