Replies: 1 comment
-
More than 2x improvement on FCP is impressive! Really shows the power of async, where loading more requests concurrently performs so much faster than a single one. The configuration options for async vs inline vs blocking are cool as well, to have flexibility regarding CLS. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
For years, we've been chasing the dream of individually scoped components for our CSS. While we've achieved that, bundling everything into a single file has been a necessary compromise to ensure fast load times by reducing the number of requests. However, this approach introduced its own challenges:
With performance improvements in browsers, networks, and devices, we questioned if this bundled approach was still necessary. Could we deliver individually scoped CSS files asynchronously or inline them without significant performance costs? This post explores our findings and the shift to a no-build, component-based CSS workflow.
The problem with a single CSS bundle
The New Approach: Component-Based CSS
How It Works
inline_asset_content
.Performance Comparison
Summary
Testing Conditions: Chrome w/ 20x CPU slowdown + emulated 3G (exaggerated conditions by todays standards)
Bundled CSS
Here we can see how things typically flow when you depend on a single CSS bundle:
NoBuild CSS
Implementation Details
Here's our first crack at a new
stylesheet
component that automatically detects whether to inline or async request a stylesheet. You can even manually provide overrides, e.g cart drawer styles that are included in the header.Observations
request.new_session
value that would allow us to inline styles + preload the duplicate external style sheet versions async, and then not inline styles for subsequent navigations, something like:Closing Thoughts
We're excited by these test results! We've improved performance, eliminated build complexity, and created a more maintainable codebase. While this approach isn't perfect, the benefits far outweigh the drawbacks.
Have you experimented with bundling alternatives or component-based CSS? We’d love to hear about your challenges, successes, and insights. Drop us a comment!
Beta Was this translation helpful? Give feedback.
All reactions