What’s the latest writing/research/best-practices on bundling versus code splitting? Large requests versus splitting into smaller ones?
Hoping for something a bit more nuanced than “reducing download size is good” or “reducing network count is good.”
24 replies
@zachleat The latest researched take I’ve seen is @csswizardry’s article: https://csswizardry.com/2023/10/the-three-c-concatenate-compress-cache/ (tl;dr at the end)
@knowler @csswizardry excellent, thank you!
@zachleat You want nuance? https://askastaffengineer.com will always have your back.
Courtesy of @ksylor 😂
@zachleat I ran a test on this with CSS recently. got slightly different results than the Harry Roberts article that was linked in another toot https://gomakethings.com/modular-css-and-different-ways-to-structure-your-stylesheets/
@cferdinandi I would say that “a concatenated file is still the most performant for people on the slowest connections and oldest devices” is only true if the concatenated file weight is low, don't you think?
On my side, as I don't have much CSS code, I even inline it all. There is no CSS network request on https://nicolas-hoizey.photo/
My tests in the past showed that is was faster than requests. Because there is not much CSS.
@nhoizey @cferdinandi yeah! I’m interested to learn at what inflection point does it start to break down (and if you fancy, what inflection point for different network connections)
@zachleat I'm not sure anyone did try with different file weights to find the inflection point.
Also, I'm not sure it’s worth it trying to have a dynamic solution to account for different network connections. It's already complicated enough! 😅
@nhoizey @cferdinandi not looking for a dynamic solution, just research!
-
-
@nhoizey @zachleat @cferdinandi it also depends on so many other factors that you can't formulate a rule of thumb. For example, if you run nginx, then inlining CSS leads to much better FCP and LCP, as it will not send the CSS until the HTML is fully sent over the wire: https://x.com/derSchepp/status/1595334081969020928?t=O6P8EI8Gf_3hNjonQz0wRQ&s=19
@Schepp without an X account, I can't read the responses to your tweet, were there any?
@nhoizey @zachleat @cferdinandi Here is the thread screenshotted. The bug report mentioned is this one: https://issues.chromium.org/issues/41392507
@Schepp thanks! 🙏
From what I read in the bug report, Pat Meenan said “it's not likely to work in practice for most origins where it's lucky if they even support prioritization at all”… 😞
So it looks like inlining critical CSS is important indeed, even more for large HTML documents.
But inlining CSS is complex and can be detrimental, as shown by @csswizardry: https://csswizardry.com/2022/09/critical-css-not-so-fast/
@nhoizey @csswizardry @zachleat @cferdinandi yes, as always, things are more complicated than initially anticipated. It always depends on the specific setup.
@Schepp always indeed. 😅
@cferdinandi I agree 👍
@zachleat "Minimum Viable Chunk" is a good deep dive into the complexity of the problem and the trade offs you're forced to make.
https://www.youtube.com/watch?v=ImjzA7EMI6I
Unfortunately it kind of ends with "You should do it like Google does, but no open source tools on the market actually do that so 🤷♂️."