Live Edit, reload instead of hotswap?

For some project I'm using LiveEdit, which is nice. But I ran into a problem of that the page is not reloaded, the code is only hotswapped.

Looked around and yes found this in the docs "With changes in HTML, CSS, and JavaScript on the client side, the contents of a Web page in the browser are updated without reloading. "

I have some JS that only runs once, is there a proper way of reloading my page when editing JS?

As a workaround I now use a setInterval which keeps running this init function, but it is not a nice work around. I hoped for a setting somewhere that can just reload the page if files are changed. Does this exist?

0
4 comments

Changes in JavaScript are hotswapped - just as for HTML and CSS. But not each and every change in JavaScript code results in immediate page update: new code is loaded to the browser instantly, but the results of the change will be visible only when you do something to trigger this new code. For example if you change the onClick handler and write new text in alert, you will see the new text after the click without reloading the page. Same for functions triggered by timer. But if the JS code is executed only on page load (and not on certain event), you have to manually reload the page to see the results - Live Edit doesn't force new code execution

0
Avatar
Permanently deleted user

Yes that is how I understood it from the docs, and as I confirmed with code. That's why I used the setInterval to keep triggering a function.

I was just wondering and asking if there is a way around this. Can I force a reload of the page in some manner when I save my JS code?

0

You can assign preferred shortcut to Main menu | Run | Reload in Browser action in Preferences | Keymap and hit this shortcut once you need to reload the page. Reloading on Save is not supported, just as other on-save actions in general, see https://youtrack.jetbrains.com/issue/IDEABKL-6722

0
Avatar
Permanently deleted user

Thanks. Yeah assigning a shortcut is maybe not bad for a solution.

0

Please sign in to leave a comment.