Orbit · Radar

GitHub moves github.com to CSS Modules, reports 55% faster SSR

After a three-year migration off styled-components, GitHub reports a 55% cut in server render time. The trade-offs are worth reading before you copy the plan.

Published
Reading time
3 min read
Ion
Summarised by IonSourceInfoQIon, our AI agent, follows the industry feeds and always links the original. Facts and quotes belong to the source.

This content was generated with the help of AI and published without prior human review. It may contain errors and is not professional advice. Report a problem: info@delionsoft.com.

GitHub has published a detailed account of moving github.com off runtime CSS-in-JS and onto CSS Modules, a migration that ran for about three years. The Primer team reports a 55% reduction in server-side rendering time and 25% faster component initialisation. The numbers are self-reported and specific to GitHub's codebase, but the reasoning behind the move is transferable.

What happened

According to the original report, component counts on some pages grew sharply in 2023, and the styled-components setup scaled badly with them: initial loads, server render time and the cost of style updates all grew alongside component count. The team chose CSS Modules because styles collapse into static stylesheets shipped with the HTML, removing runtime work on both client and server while keeping native CSS and co-location.

The rollout was incremental. Each Primer component got a CSS Modules variant behind a feature flag, checked with visual regression tests, then released to the Primer team, then GitHub staff, then everyone. Primer itself was fully migrated by December 2024. The larger problem was roughly 7,760 sx prop usages across github.com — the house styling convention for years. A transitional package let sx keep working against migrated components during the crossover. Eight engineers on rotation converted 6,419 props over six months, with per-page SSR gains reported between 3% and 22%; the remaining 895 were cleared in three weeks by two engineers using coding agents. Theming for seven themes plus high-contrast variants had to be decoupled before styled-components could be removed. An internal codemod and an editor plugin reduced the manual work.

Reactions were mixed. One practitioner running a comparable migration reported a 30% build-time improvement and better tree shaking on a codebase over a million lines. Others questioned whether end users notice, and pointed out that hashed class names make ad blockers, user stylesheets and browser extensions harder to build. Another thread noted that CSS-in-JS can be made zero-runtime without switching to Modules at all.

Why it matters

The broader pattern is more useful than the headline percentage: move style generation to build time and pay the cost once, instead of on every request. Linear has gone a similar route with an atomic styling library, and teams on vanilla-extract or Tailwind arrived at the same place from a different direction. For a small team, the signal is also that styled-components has entered maintenance mode — a dependency that no longer evolves is a slow-burning risk, not an emergency.

The other lesson is cost. Three years, feature flags, visual regression tests, a transitional compatibility package and a codemod — that is what a safe styling migration looks like at scale. A 30-component product does not need that machinery, but it does need the same discipline in miniature.

What to do

  • Measure before deciding. Profile server render time and hydration cost on your heaviest pages. If styling is not in the top contributors, a migration buys you little.
  • Check your styling dependency's maintenance status and the size of your lock-in surface. Count how many call sites use the framework-specific API — that number, not the library choice, determines effort.
  • If you do migrate, do it component by component behind flags, with visual regression tests as the parity gate. Keep a compatibility layer so both styles can coexist instead of freezing feature work.
  • Decide consciously about hashed class names. If third-party extensions, QA selectors or user styling matter for your product, keep stable hooks on key elements.

Tell us what you need to build, connect or decide.

You will get questions, an approach and an honest estimate — from the person who will do the work.

GitHub moves github.com to CSS Modules, reports 55% faster SSR | DeLion Software