I’m using a lot of javascript on my site and of course sometimes things go wrong when building code and bugs appear. Sometimes the page runs into a bug and all scripts stop working. This is especially true if a bug is triggered during page load. And sometimes some bugs don’t seem to stop the page from running more scripts.
And then sometimes I look at some pages on the web, press F12 and I see that the page has 5-10 javascript bugs and yet just keeps working seemingly fine.
What makes some javascript error fatal and others recoverable?
Thanks.
When
<script>blocks are evaluated by the browser upon loading, the code is actually executed in addition to their being parsed. Thus, exceptions during that process cause the entire script block to be aborted. If subsequent code relies on global symbols that should have been established by such a script, but weren’t due to error, the other scripts may also fail.However, an error during the handling of some event just causes that event loop to be aborted. A code error in a “click” handler, therefore, just means that some things that should happen when something is clicked simply don’t happen. Otherwise, the page can continue to work normally.