https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-core/gather/gatherers/dobetterweb/tags-blocking-first-paint.js#L58 only checks for script in <head>.
We should expand that to cover blocking scripts within <body> (example). False positives will likely be trickier to deal with. Strawman below.
For all scripts in <body>:
- Determine if the script is before the end of the page (
document.body.lastElementChild).
- If it's not at the end, check if there's rendered DOM after it. Filter out
script, template, and anything else in the default stylesheet that's hidden by default.
- For all the sibling nodes after the script, check
node.offsetParent === null to determine if it is being rendered. Note: cannot use getComputedStyle(node).display === 'none won't work as expected.
We'll need to also update the reference do, which talks about scripts in the head:
https://developers.google.com/web/tools/lighthouse/audits/blocking-resources
cc @igrigorik
https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-core/gather/gatherers/dobetterweb/tags-blocking-first-paint.js#L58 only checks for
scriptin<head>.We should expand that to cover blocking scripts within
<body>(example). False positives will likely be trickier to deal with. Strawman below.For all scripts in
<body>:document.body.lastElementChild).script,template, and anything else in the default stylesheet that's hidden by default.node.offsetParent === nullto determine if it is being rendered. Note: cannot usegetComputedStyle(node).display === 'nonewon't work as expected.We'll need to also update the reference do, which talks about scripts in the head:
https://developers.google.com/web/tools/lighthouse/audits/blocking-resources
cc @igrigorik