4 ms·
Nowadays it's probably better to just prompt the browser to preload CSS early with a link preload header. Any page complicated enough to need critical CSS extr
by wonnage 4y ago
Nowadays it's probably better to just prompt the browser to preload CSS early with a link preload header.
Any page complicated enough to need critical CSS extraction is probably also going to take 50-100ms to render and transfer to the user. Just send the headers before you render and the client will probably have finished downloading them by the time you're done.
If clients are on a crappy network, critical css is even worse of an idea because they'll scroll down and get a broken page for 5 seconds
- laundermaf 4y agoI don’t find the HTTP headers approach useful. Headers only appear a few bytes before the HTML so if you keep the regular link tag right at the top of the file you’re good to go; no need to mess with headers. Every HTML file should start with: doctype, html tag, head tag, charset meta tag, title, stylesheet link tag. A couple of those tags are even optional.
- porker 4y agoOnce HTTP 103 is better supported this will improve.
- youngtaff 4y agoOnly if there’s a gap between the 103 response and the head content arriving
- wonnage 4y agoThe header approach is easier to graft on to an existing system where the entire html document is generated in one go. Otherwise you have to deal with generating the response in chunks which can be nontrivial.