Scripts loaded after the main load event are considered as blocking if they are prefetched in the head.
It is exemplified in this gist, where in the document's head a
<link as="script" src="/main.js" rel="preload">
tag is present and at the end of the body the preloaded script is added by
document.createElement('script')
script.src = '/main.js'
document.head.appendChild(script)
(Opened after https://github.com/google/WebFundamentals/issues/4694)
Hm we didn't do the same handling for scripts that we did for links since defer and async make it a much less common use case. What's the primary benefit of this method over marking as async?
What's the primary benefit of this method over marking as async?
It's that I can chain multiple script loads, having control over the request order.
I see, and the script elements need to be appended to the head, not the body?
That's not important, in facts the fastest solution was to change that.
I'm opening this issue just to notify it 😉
gotcha thanks for the report! :)
We think isLinkPreload from here https://chromedevtools.github.io/devtools-protocol/tot/Network/#type-Request will sort this out... But also it's implemented like this already. TBD!
Hi. There. I think that This issue is DONE.
https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-core/gather/gatherers/dobetterweb/tags-blocking-first-paint.js#L130