Hacker News new | ask | show | jobs
by jlokier 2005 days ago
> That means the browser stops parsing the HTML mid-way through the page load, resolves the CDN's domain to IP, does a TLS handshake and establishes a connection to the CDN, waits to download the script, parses, runs it, and then proceeds on to the rest of the HTML.

This is not true since about 2008. All major browsers parse the HTML without waiting for synchronous <script> to load. https://developer.mozilla.org/en-US/docs/Glossary/speculativ...

If the <script> uses document.write() and what's written contains unbalanced tags, or if the document is modified in some other ways, then they re-parse but that combination is rare. This page explains what to avoid to ensure re-parsing doesn't happen (the rules may differ with other browsers): https://developer.mozilla.org/en-US/docs/Glossary/speculativ...

1 comments

You're right, I stand corrected on the parsing bit I mentioned, which to be honest is a nuance I had not heard of. But it doesn't change my point much. Using script tags without `defer` will still delay the page load. They might not block parsing, but they will still block rendering. Both matter when it comes to seeing anything on your screen at all.