Open DrewML opened 5 years ago
Some discussion about this happened with Google folks on twitter
https://twitter.com/drewml/status/1177035220295413760
It's possible that this will be fixed when https://bugs.chromium.org/p/chromium/issues/detail?id=651538 is addressed. Trying to get more info on the changes
In Chrome, a
preload
tag ends up pushing the priority of a resource ahead of any other, non-preloaded resource. This is detrimental to the FMP time, because CSS ends up prioritized after the preloaded JS.Note the special treatment of
core-bundle.js
, getting its first byte before any other assetNote: The timeline above shows all resources sharing bandwidth, but devtools is lying. Each resource is getting downloaded exclusively
Asset order in the DOM
I verified through
chrome://net-export/
that Chrome is signaling to the server thatcore-bundle.js
should be the first resource sent after the initial HTML Document. Below are the streams for the first few critical assets, in the order the streams were created:Looking through
HTTP2_SESSION_RECV_DATA
events in the net export log, you can see the real order the server flushed the responses in below. Note that Chrome used theexclusive
bit on every stream, so assets are given 100% bandwidth and downloaded in the order specified between stream weight and priorities.Real Download Order:
core-bundle.js
andcalendar.css
are both given a parent stream ID of0
. According to the H2 spec, when theexclusive
bit is used and multiple dependencies are added to a parent stream, it should create this treeBecause of this,
core-bundle.js
gets downloaded before any of the css on the page, even though the CSS has a higher stream weight. It seems like usage of the exclusive bit on every stream causes stream weights to be ignored, based on my reading of the spec. In particular, these 2 parts:Since the
exclusive
bit on every stream means no 2 resources will share a parent, the stream weight is never used.IMO, Chrome's handling of H2 priorities here is wrong/buggy. If Chrome knows it's going to assign a higher weight to
calendar.css
than tocore-bundle.js
, it should be makingcalendar.css
a dependency of parent 0 beforecore-bundle.js
, which would result in the JS being prioritized immediately after the CSS, fixing the FMP timing.