GitHub Moves github.com From styled-components to CSS Modules, Cutting SSR Time by 55%
GitHub says a three-year migration of github.com from styled-components to CSS Modules cut server-side rendering time by 55% and sped up component initialisation by 25%. The move covered thousands of style props across its Primer design system.

TL;DR
- GitHub moved github.com from runtime CSS-in-JS (styled-components) to CSS Modules over three years.
- The team reports a 55% reduction in server-side rendering time and 25% faster component initialisation.
- The work involved feature-flagged rollouts, visual regression tests and roughly 7,760
sxprop usages.
Why the old setup stopped scaling
GitHub's Primer engineers, Josh Black and Marie Lucca, describe how component counts on some pages began growing sharply in 2023. That exposed scaling problems in the styled-components setup. Page load time, server render time and the cost of updating styles all rose with the number of components.
The team chose CSS Modules because it keeps native CSS features and lets styles sit next to the components that use them. It also removes styling work at runtime on both client and server. Styles are compiled into static stylesheets that ship with the HTML.
How the migration was carried out
For each Primer component, the team added a CSS Modules variant and hid it behind a feature flag. They checked parity with visual regression tests, then rolled it out first to Primer's own team, then to GitHub staff, and finally to all users. By December 2024, Primer itself ran entirely on CSS Modules.
The harder part was the sx prop, which had been the de facto styling standard across github.com for years. Roughly 7,760 usages were spread through the codebase. A transitional @primer/styled-react package let sx keep working against migrated components while the two systems overlapped.
A typical change moves a styled button from an sx object to a CSS Module class. The component is imported from @primer/react and the styles come from a .module.css file instead of inline style objects.
The pace varied. A rotation of eight engineers migrated 6,419 props over six months, and per-page SSR gains ranged from 3% to 22%. The last 895 props were cleared in three weeks by two engineers who relied heavily on Copilot coding agents. GitHub also had to separate theming from styling for its seven themes and high-contrast variants before it could remove styled-components completely. A VS Code plugin and an internal codemod reduced the manual effort. GitHub noted that styled-components entering maintenance mode also supported the decision.
What the community is saying
InfoQ reports mixed reactions. One Hacker News commenter running a similar migration on Next.js across a codebase of more than 1M lines reported a 30% build time improvement and much better tree shaking. Others doubted the effect on end users. One argued that the size reduction was too small to justify making class names unreadable, and that hashed class names make it harder to build ad-blockers, custom CSS and browser extensions. Another commenter pointed out that CSS-in-JS can be made zero-runtime without switching to CSS Modules.
A wider shift away from runtime styling
GitHub is not alone. InfoQ notes that Linear finished a 1,000-PR move from styled-components to Meta's atomic StyleX library, citing render-time concerns. Other teams using vanilla-extract or Tailwind have moved style generation entirely to build time. The common idea is to do the work once at build time rather than on every request.
Why it matters
Teams running styled-components or similar runtime CSS-in-JS libraries have a concrete example of what a migration can involve: feature flags, visual regression tests, a compatibility layer, and codemods for the old API. The reported gains are GitHub's own figures on its own codebase, so results on other stacks will differ. Teams that want to start should look at the Primer React v38 release notes and the migration guide covering the move from sx props to CSS Modules. Build-time approaches like vanilla-extract or Tailwind are other options that avoid per-request style work.
Sources
This article was written by Blozhik from the reporting below. Read the originals for full detail.
InGitHub Ditches CSS-in-JS for CSS Modules, Reports 55% Faster SSR After Three-Year MigrationInfoQKeep reading


