Skip to content

GitHub CSS Modules Migration Cuts Server Rendering Time by 55%

GitHub has completed its migration from CSS-in-JS to CSS Modules across github.com, reporting major server-rendering gains and a safer path for large-scale frontend styling changes.

GitHub CSS Modules Migration Cuts Server Rendering Time by 55%

On this page

GitHub has finished moving github.com away from CSS-in-JS, completing a multi-year frontend styling migration that reached 100% CSS Modules coverage in June 2026. The change was driven by a practical problem: as component-heavy pages grew, runtime style generation was adding work to both browsers and GitHub's servers. GitHub says the earlier Primer migration reduced server-side rendering time by 55% and component initialization time by 25%, while later migrations produced smaller but measurable gains on individual pages.

GitHub's CSS Modules migration started with a scaling problem

The problem became visible in 2023 as the number of components on some GitHub pages increased sharply. GitHub says its existing CSS-in-JS implementation made initial page loads slower because styles had to be initialized on the client, while server-side rendering also became more expensive as styles were collected during rendering. Style updates became harder to control as component counts grew.

CSS-in-JS means writing styling rules alongside JavaScript and generating or managing those rules while an application runs. That model can make component styling convenient, but its runtime work becomes part of the rendering path. GitHub's experience is therefore less about declaring CSS-in-JS universally bad and more about what happens when runtime styling is multiplied across a very large component system.

CSS Modules moved the styling work out of the runtime

GitHub chose CSS Modules because they preserve some of the component-level organization developers expect from CSS-in-JS without requiring styles to be processed at runtime. A CSS Module is an ordinary CSS file whose class names are locally scoped by the module system, so two components can use the same human-readable class name without creating a global selector collision. The build process converts those local names into safe output names and produces CSS that can be delivered to the browser.

That distinction matters for performance. With the approach GitHub describes, the browser receives CSS in stylesheets instead of waiting for JavaScript to generate the corresponding rules, while the server no longer needs to perform the same style-collection work during rendering. CSS Modules do not make CSS itself faster; they change when styling work happens and remove a class of runtime work from the rendering path.

The first migration delivered the clearest performance evidence

GitHub did not replace everything in one deployment. The Primer design system team converted components individually, placed each change behind a feature flag, compared visual-regression results, and gradually exposed the new implementation first to internal teams, then GitHub staff, and finally all users. By December 2024, GitHub says every component in Primer had moved to CSS Modules.

The results gave the team a reason to continue. GitHub measured 55% less server-side rendering time for a page and 25% less time for components on a page to initialize after the Primer migration. Those figures are measurements from GitHub's own environment, not a general benchmark showing that every React application will become 55% faster after adopting CSS Modules.

The harder problem was thousands of sx props

Moving the design-system components was only part of the job. GitHub had used the sx prop to let teams customize Primer components with inline style objects, giving developers strong TypeScript support and convenient access to design tokens. The same flexibility also created runtime work because those dynamic objects had to be processed as the application ran.

GitHub therefore had to migrate existing sx usage before it could remove its remaining CSS-in-JS dependencies. To avoid breaking consumers, the team created a temporary @primer/styled-react wrapper that allowed old sx-based usage to coexist with the new CSS Modules implementation. Components could then move to the new system without forcing every caller to migrate on the same day.

GitHub turned a risky rewrite into a six-month migration

The large-scale sx conversion began in April 2025, when GitHub says it had roughly 7,760 sx props to migrate. Eight engineers eventually migrated 6,419 props over six months, with server-side rendering improvements ranging from about 1% to 22% on some pages. GitHub also built automation around the work, including a Visual Studio Code plugin and a codemod that could convert entire files while leaving engineers to validate the more difficult cases.

The final stretch shows why large frontend migrations are often more about process than syntax. In April 2026, GitHub says two engineers reduced the remaining count from 895 sx props to zero in three weeks, using extensive automation and Copilot coding agents. The company still had to separate JavaScript-based theming from the remaining CSS-in-JS dependencies before it could remove those dependencies completely.

The final result was more than replacing one styling library

GitHub says github.com has run entirely on CSS Modules since June 2026, with sx, styled-components, and styled-system removed from dotcom. The migration also covered the site's seven themes and their high-contrast variants, so removing the old styling system required work beyond simply changing component imports.

That makes the GitHub case useful to frontend teams because the difficult part was not learning CSS Modules. The difficult part was maintaining compatibility while thousands of existing components and style customizations were moved. The feature flags, visual tests, wrapper package, codemods, staged releases, and production measurements formed the migration strategy around the technology change.

GitHub's numbers show where CSS architecture can matter

The strongest performance gains appeared where runtime styling was directly involved in expensive rendering paths. GitHub's initial Primer result showed a 55% reduction in server-side rendering time, while later package migrations produced improvements between 1% and 22% on some pages. That spread is significant: it shows that the benefit depended on what each page was doing rather than representing a universal percentage that developers can apply to their own applications.

Another recent frontend migration points in a similar direction without using the same replacement. Linear completed a move from styled-components to Meta's StyleX after more than 1,000 pull requests, citing runtime styling costs and performance considerations in its React applications. StyleX is still a CSS-in-JS approach, however, so the two projects should not be treated as evidence that every team should simply abandon CSS-in-JS. They show instead that large React applications are increasingly examining the cost of runtime styling as their component systems grow.

The lesson for smaller React applications is not to copy GitHub blindly

A small application with a limited component tree may not have the same runtime styling costs GitHub encountered. Replacing a working styling system can also introduce migration effort, visual regressions, unfamiliar conventions, and build-tool changes that outweigh a performance gain that users would never notice. CSS Modules also remain a build-time convention rather than a browser-native styling primitive; their value comes from the way tooling transforms locally scoped CSS into ordinary browser-consumable stylesheets.

For teams considering a similar move, GitHub's process offers a more transferable idea than its headline performance numbers: measure the existing rendering path first, migrate one component family at a time, keep visual regression coverage in place, and use feature flags where a styling change can affect production UI. The useful question is not whether CSS Modules are faster in the abstract. It is whether removing runtime style work from your application's critical rendering path produces a measurable improvement worth the migration cost.

M. Rizwan Mirza profile photo

Written by

M Rizwan Mirza

I’m M Rizwan Mirza, a Full Stack Developer with over 12 years of experience in web development and software solutions. I work with modern web technologies and enjoy building practical, reliable, and user-friendly digital solutions. I’m also part of TechWare House, where I work on web development projects and technology solutions. One of my favorite websites is TheQuranic.com. Through WizTechnoz, I share my knowledge, experience, tutorials, and useful insights about technology.

86 posts published

All posts by this author

Copy this post

0 Comments

No comments yet. Be the first to share your thoughts.

Join the conversation

Log in or create a free account to leave a comment. You can edit or delete your own comments any time.