Run loaded script again (after modification) in Browser's Inspect Tools?

583 views Asked by At

For example, on page I have a button, which causes to fire XYZ function (which is already loaded inside namespace in external JS).

enter image description here

However, I wanted there to change only one function in that script only (not page), and reload that script again, so, that the BUTTON will fire the modified function..

How to do that?

1

There are 1 answers

0
Z-Bone On

Shouldn't be a problem. You can use the console to redefine the function.
Just click F12, go to Console, then type in your edited function and click enter.

Then click the button and the modified function will be executed.

Note When editing the function from the console, make sure that you are in the right context:
enter image description here

If you type the function name and get a function this means you can edit it. If you get undefined, this means you are not in the right context and should change the scope in which the function is defined in. You can change scope in Chrome's console if needed by using this dropdown (for example when the code is run from an iframe):
enter image description here