GitHub has detailed its three-year effort to transition github.com from CSS-in-JS, specifically styled-components, to CSS Modules. This migration has led to significant performance improvements, including a 55% reduction in server-side rendering (SSR) time and a 25% increase in component initialization speed within its Primer design system.
The decision to migrate stemmed from scaling problems identified in 2023, as the number of components on certain pages grew. This growth led to increased initial page load times, server render times, and style update costs with the existing styled-components setup. CSS Modules were chosen for their ability to retain native CSS features and co-location while eliminating client and server runtime overhead, allowing styles to be delivered as static stylesheets with the HTML.
The migration involved creating CSS Modules variants for every Primer component, gating them behind feature flags, and verifying visual parity before a phased rollout. The more complex part involved migrating approximately 7,760 instances of `sx` prop usages across github.com. A transitional `@primer/styled-react` package facilitated compatibility during the crossover period. A team of eight engineers migrated 6,419 props over six months, observing SSR improvements between 3% and 22% per page. The remaining 895 props were completed by two engineers in three weeks, utilizing Copilot coding agents. Decoupling theming for GitHub's seven themes and high-contrast variants was also necessary before fully removing styled-components. Internal tools like a VS Code plugin and codemods helped reduce manual effort.
The move aligns with broader industry trends, as styled-components has entered maintenance mode. Other developers undertaking similar migrations have reported benefits such as 30% build time speed improvements and better tree shaking in Next.js projects. However, some community members have expressed skepticism regarding the user impact, citing concerns about the readability of hashed CSS class names and potential difficulties for ad-blockers, custom CSS, and browser extensions.
✨ This summary was generated by AI from the outlets' reporting listed below. It is not independently verified and may contain errors — check the original sources. How BrevFeed works →
One email each morning: the day's tech stories, clustered across outlets and summarized. No account needed.
One email a day. Unsubscribe in one click, any time.
Spend a few minutes, get the whole day. Every topic's top stories in one hands-free rundown — listen, watch, or read the transcript.
▶ Play today's briefNew every morning, and the back catalogue is archived by date.
GitHub completed a three-year migration of github.com from CSS-in-JS (styled-components) to CSS Modules, resulting in a 55% reduction in server-side rendering time and 25% faster component initialization. This change addresses scaling issues encountered with increasing component counts and improves initial page loads by delivering static stylesheets.