Thanks for the great post. I did notice something that doesn't seem quite right regarding async scripts:
[A plain script tag] blocks parsing of the rest of the page until it's loaded and executed. For that reason, the async attribute is helpful. It'll request the script in the background at low priority, and execute as soon as it's ready. Knowing this, the following setup behaves predictably. [...] But at the same time, you don't want it to block the rest of the page from parsing.
It turns out that an async script can actually block rendering, especially if it is already in the browser cache. In this way, it is not predictable whether an async script will execute while the page is loading or after it has loaded. To ensure that a script never blocks rendering, it should use defer rather than async. Here's some more info on that: https://github.com/WordPress/gutenberg/pull/52536#issuecomment-1641778217
Weston Ruter
1 total comments
9/21/2023, 7:50:55 PM
Thanks for the great post. I did notice something that doesn't seem quite right regarding async scripts:
It turns out that an async script can actually block rendering, especially if it is already in the browser cache. In this way, it is not predictable whether an async script will execute while the page is loading or after it has loaded. To ensure that a script never blocks rendering, it should use defer rather than async. Here's some more info on that: https://github.com/WordPress/gutenberg/pull/52536#issuecomment-1641778217
page 1 of 1