Simple question.
When a browser is parsing a JavaScript file, does it block the main thread?
I mean, is the browser responsive during that time? Is it possible to scroll or does it get stuck?
I've thought of this question after reading the article below:
Parsing JS does not block the "main thread", at least that's the behaviour you can observe on modern browsers. The page however is loaded from top to bottom, so if there is JavaScript inbetween, that JS will get downloaded and parsed before the rest gets evaluated.
Already shown
<script>while(true);</script>
Not shown.
Therefore it is best practice to either mark your <script>
s as deferred or async, or move them to the bottom of the page.
CNN is probably doing that too. The point is in the details:
is fully interactable
As websites nowadays pretty much depend on JS for interactivity, you can't do much without it.