NewsCrawler.org

GitHub moves github.com from CSS-in-JS to CSS Modules; SSR time falls 55%

GitHub moves github.com from CSS-in-JS to CSS Modules; SSR time falls 55%
Image: Reddit

GitHub has published an account of a three-year effort to move github.com from CSS-in-JS[1] to CSS Modules[2]. Primer, GitHub's open-source component library, began to see component counts on some pages rise sharply in 2023, which exposed scaling problems with the existing styled-components setup.

The team reports a 55% reduction in server-side rendering (SSR)[3] time and 25% faster component initialization across its Primer-powered design system. For each Primer component, the team added a CSS Modules variant, put it behind a feature flag, checked it with visual regression tests, and rolled it out first to GitHub staff and then to all users. By December 2024, Primer itself was fully on CSS Modules.

Of roughly 7,760 sx prop[4] usages, a rotation of eight engineers migrated 6,419 over six months, and two engineers cleared the final 895 in three weeks with heavy help from Copilot coding agents. A VS Code plugin and an internal codemod reduced manual work, and the article says styled-components entering maintenance mode reinforced the direction. Linear recently completed its own 1,000-PR move from styled-components to Meta's StyleX library, and other teams have moved style generation to build time with vanilla-extract or Tailwind.

Read the original infoq.comDiscussion

Discussion

Commenters mostly agree that runtime CSS-in-JS adds render cost, and one suggests zero-runtime options such as vanilla-extract or Panda CSS as a way to keep the co-location without that cost. Others question the three-year timeline and argue that a separate CSS file per route would have been simpler from the start.

Sources

Published: First seen: Читать по-русски

Open as a page