DescriptionFixed resource scheduler to not treat non-blocking js as render-blocking
Prior to https://codereview.chromium.org/462813002 the resource
scheduler would exit the critical loading phase as soon as the main
parser parsed the body tag:
- Blocking JS in the head would keep it in the critical phase
- CSS in the head would not (this is the bug that was fixed)
- Non-blocking JS or JS discovered by the preload scanner would NOT
keep it in the critical phase.
After the fix:
- Blocking JS in the head still kept it in the critical phase
- CSS in the head kept it in the critical phase (fix worked)
- Any JS that was started before the body tag was parsed would keep
it in the critical phase until that JS finished loading. This inclues
non-blocking JS (script-injected while in the head) as well as JS
discovered by the preload scanner.
This change keeps the CSS fix but also restores the JS behavior so
that non-blocking or preload-scanned JS no longer keep the loader
in the critical resources phase.
The fix was really simple since CSS loads at a higher priority
than JS (net::Medium), I just changed the logic to only count
Medium+ as render-blocking (waiting for them to finish regardless of
the state of the body tag) and returned the logic that unblocks
non-render-blocking resources as soon as the body tag was parsed (which
now includes JS). Any blocking JS still keeps the main parser blocked
so only non-blocking and preloaded JS would be pending or loading when
the body tag is parsed.
You can see it working here:
http://www.webpagetest.org/video/compare.php?tests=141016_WH_e488a05d7b224d7fc362dfa91b7c5ec6,141016_H1_2ecb3d397b3c218ff26dc7bdb9cb0858
Request #13 is a non-blocking script that in teh baseline case keeps
images from being loaded but in the fixed case no longer blocks images.
The canonical test page for the CSS bug also shows the critical phase
still being honored when only css is parsed in the head:
http://www.webpagetest.org/video/compare.php?tests=141016_VM_1d25c3ff22f132b4ded97d7d72e5e558,141016_PM_17a2f0282c39f299425ba57c5c5118bf
BUG=423853
Committed: https://crrev.com/8a7d3a2d6b85c624db87d8fdea641d1214afe969
Cr-Commit-Position: refs/heads/master@{#299959}
Patch Set 1 #
Total comments: 2
Patch Set 2 : Unit test added #
Total comments: 2
Patch Set 3 : Fixed line lengths #
Messages
Total messages: 11 (2 generated)
|