lighthouse: Implement a layout-blocking property on networkrequests in Blink
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 usegetComputedStyle(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
About this issue
- Original URL
- State: open
- Created 7 years ago
- Comments: 30 (10 by maintainers)
Commits related to this issue
- [devtools-cwv] Set preloads to non-blocking Currently markup based preloads are considered blocking [1]. This CL makes sure that they're considered non-blocking, along with dynamically added preloads... — committed to replayio/chromium by deleted user 3 years ago
- [devtools-cwv] Set preloads to non-blocking Currently markup based preloads are considered blocking [1]. This CL makes sure that they're considered non-blocking, along with dynamically added preloads... — committed to mjfroman/moz-libwebrtc-third-party by deleted user 3 years ago
https://chromium-review.googlesource.com/c/chromium/src/+/2626665 landed! (including redirect support) Let the tracing begin!! 😃
🎉 soon we’ll have a trace event for render-blocking styles: https://chromium-review.googlesource.com/c/chromium/src/+/2626665
https://chromium-review.googlesource.com/c/chromium/src/+/5208571
With the latest changes to Chrome, the trace’s
renderBlocking
signal matches Lighthouse’sTagsBlockingFirstPaint
fordbw_tester.html
:I also agree that
<link disabled>
should not trigger a fetch. We only recently changed the behavior here, but that seems to have settled out without compat issues. Perhaps we could try making this change now? I’m happy to give it a try, unless you’d like to do it.I just +1’d your CL for this.
What’s a
<link rel=import>
? That’s so Feb 2021 - they’re now gone. 😄My hunch is that https://cs.chromium.org/chromium/src/third_party/blink/renderer/core/script/html_parser_script_runner.cc?type=cs&sq=package:chromium&g=0&l=111-126 will do nicely. I haven’t tried yet 😃