Webstorm Live Edit not working for an external JavaScript file

大兔子大兔子 提交于 2019-12-07 13:51:41

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/24033586/webstorm-live-edit-not-working-for-an-external-javascript-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!