AI-generated editorial illustration; not a documentary photograph.
GitHub has completed a multi-year migration of its dotcom frontend from CSS-in-JS to CSS Modules, with the company saying the site has run on 100% CSS Modules since June 2026. The change affects the Primer design system and the wider GitHub codebase, where teams had relied heavily on styled-components and the sx styling prop.
Why GitHub changed course
GitHub's engineering team said the number of components on some pages grew sharply in 2023, increasing the client and server costs associated with its existing CSS-in-JS approach. CSS Modules let teams keep component styles alongside JavaScript while making class names local by default. The resulting styles are assembled into CSS stylesheets sent with the page, without client or server runtime behavior for styling.
A staged Primer migration
The Primer team migrated its components incrementally, using feature flags and gradual production rollouts to identify breakage and measure performance. A compatibility package, @primer/styled-react, allowed components still using sx to consume the migrated implementations while other code moved directly to @primer/react. All Primer components had moved to CSS Modules by December 2024.
Thousands of props to remove
The broader migration required GitHub to reduce thousands of sx props before it could remove the remaining styled-components dependencies. GitHub reported that a rotation of eight engineers migrated 6,419 props over six months, with server-side rendering improvements ranging from 1% to 22% on some pages. The work began with about 7,760 props in April 2025 and later reduced a remaining 895 to zero in three weeks with two engineers and Copilot coding agents.
What remained difficult
The final dependency cleanup also required separating GitHub's seven themes and their high-contrast variants from JavaScript utilities powered by styled-components. GitHub says feature flags, production testing, manual validation and incremental repairs helped it complete the change without breaking the site. The reported performance results come from GitHub's own engineering account; the source does not provide independent measurements.
Source: Improving site performance by shipping more CSS

Leave a Reply