GitHub OldJosh Black7 min readadvanced
Improving site performance by shipping more CSS
Summary
GitHub migrated its frontend from CSS-in-JS (styled-components) to CSS Modules to resolve performance issues like slow SSR and client-side style initialization. This multi-year effort, involving incremental rollouts and automated tooling, resulted in significant performance gains, including 55% faster SSR for Primer components and up to 22% improvement from `sx` prop removal.
- CSS-in-JS caused slow initial page loads, server-side rendering, and style updates at GitHub's scale.
- Migration to CSS Modules eliminated client/server runtime costs by shipping static CSS stylesheets.
- An incremental strategy used feature flags, visual regression tests, and a wrapper library for safe component rollout.
- Automated tooling (VS Code plugin, codemods, Copilot agents) was crucial for migrating thousands of `sx` props.
Engineers managing large-scale frontend applications or design systems can learn from GitHub's detailed, multi-year strategy for migrating away from CSS-in-JS to improve performance and maintainability.
8/10


