CSS Modules

GitHub Cuts SSR Time 55% After a Three-Year Migration to CSS Modules

Three years of migration work paid off: GitHub cut server-side rendering time by 55% after moving from styled-components to CSS Modules.

3 min readInfoQ
GitHub Cuts SSR Time 55% After a Three-Year Migration to CSS Modules

GitHub's three-year migration from styled-components to CSS Modules, which yielded a 55% reduction in server-side rendering time and a 25% improvement in component initialization, is the kind of quiet infrastructure win that rarely makes headlines but reshapes how teams think about performance. We see this as a clear signal: the era of runtime CSS-in-JS as a default choice for large-scale React applications is ending. The numbers speak for themselves, and they speak directly to anyone who has watched their build times creep up or their server costs climb while managing a sprawling component library.

What makes this story instructive is not just the result but the method. GitHub converted Primer components behind feature flags, migrated roughly 7,760 `sx` prop usages using codemods and Copilot agents, and took three years to do it carefully. That is not a weekend project. It is a deliberate, engineering-led decision that prioritizes long-term maintainability over short-term convenience. For teams wrestling with similar choices, this offers a practical blueprint: you can move large codebases off runtime styling without rewriting everything at once. The tools exist, and the payoff is measurable. Compare this to the broader push for efficiency we are seeing elsewhere, Amazon's Decart acquisition sharpens its software strategy to close the silicon efficiency gap, where the goal is also about squeezing more performance from existing infrastructure. GitHub's approach is less about hardware and more about the decisions made in your editor, but the underlying principle is the same: better architecture yields better outcomes.

Some commenters on the migration naturally asked about user impact and the trade-off of hashed class names. Those are fair questions. A 55% SSR time cut matters most when your traffic is global and your pages need to render fast on every device. For everyday users, the improvement is invisible, they simply see pages load faster. The hashed class names, meanwhile, are a non-issue for end users and a minor inconvenience for debugging that teams can manage with source maps. What matters more is that GitHub chose a path that reduces runtime overhead without sacrificing developer experience. This is not about chasing the latest tool; it is about recognizing that every millisecond of runtime work your framework does unnecessarily is a millisecond your users wait. Two AI launches, two stark reviews: what each one gets right reminds us that not every high-profile release delivers on its promises. GitHub's migration, by contrast, was quiet, incremental, and demonstrably effective.

The specific takeaway here is direct: if your team is still relying on runtime CSS-in-JS for a large production application, you have a clear, proven alternative that can cut your rendering time in half. The migration will take time and discipline, but the performance gains are not theoretical. Watch how other major platforms respond. If GitHub can do this at scale, others will follow, and the next round of infrastructure decisions will be about what you choose to remove, not just what you choose to add.

From InfoQ

GitHub migrated github.com from styled-components to CSS Modules over three years, reporting a 55% cut in server-side rendering time and 25% faster component initialisation. Primer components were converted behind feature flags, and about 7,760 sx prop usages were migrated with codemods and Copilot agents. Commenters questioned user impact and hashed class names.

Read the original at InfoQ