Three years of work and 7,760 changes later, github.com needs less than half the server render time thanks to plain stylesheets
GitHub replaced the styled-components library with CSS Modules in its Primer design system and across the site; coding agents handled the last 895 changes.
GitHub has completed a three-year migration in which github.com and the Primer design system moved from styled-components, a library that generates styles in JavaScript at runtime, to CSS Modules, plain stylesheets built in advance and sent along with the HTML. Two Primer engineers described the move on the company's engineering blog; InfoQ and LavX News covered it on Wednesday.
The trigger came in 2023: on some pages the number of components had grown so large that load times, server render times and the cost of style updates rose with it. With CSS-in-JS, server and browser have to generate and process those styles again on every request. According to GitHub, server render time fell by 55 percent after the switch and components initialise 25 percent faster. Per page, the gains ranged from 3 to 22 percent.
By December 2024 all components of Primer React had been converted. After that, about 7,760 places on the site still used the sx property for styling. Eight engineers converted 6,419 of them in six months, helped by a transitional package, a codemod and a VS Code plug-in. Two engineers finished the last 895 in three weeks using GitHub Copilot's coding agents. Each component first got a variant behind a feature flag, with visual regression tests and a staged rollout.
According to InfoQ there were critical reactions too: the hashed class names of CSS Modules make it harder to write ad blockers, custom styles or browser extensions. Others pointed out that zero-runtime CSS-in-JS libraries also exist, so teams should first measure their own bottlenecks.