Search code examples
javascriptwebstormliveedit

Webstorm Live Edit not working for an external JavaScript file


The Live Edit feature of Webstorm 8 doesn't seem to work when using an external JavaScript file (i.e. when included with <script src="script.js"></script> in my HTML). Changes in the external JavaScript file appear only after I refresh the page.

Things work just fine for other scenarios - e.g. when I start debugging, the page in Chrome gets updated when I make changes to the HTML or CSS files, and things also work when I write some JavaScript code between <script> and </script> tags in the HTML.

What could the problem be?


Solution

  • Actually Live Edit works in both cases. But changes in embedded javascript always cause page reloading, whereas changes in 'external' javascript are hotswapped - just as for HTML and CSS. But not each and every change in external 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

    Note also that hotswapping doesn't currently work for file-level variables due to Chrome limitations - see WEB-7390