---
title: "Improving site performance by shipping more CSS"
description: "GitHub migrated its Primer Design System and the github.com codebase from styled-components CSS-in-JS to CSS Modules, removing runtime styling costs on client and server."
url: "https://swe.quest/articles/improving-site-performance-by-shipping-more-css-41480dcc45d65149"
canonical: "https://github.blog/engineering/architecture-optimization/improving-site-performance-by-shipping-more-css/"
source: "GitHub Engineering"
published: "2026-09-25"
difficulty: "medium"
kind: "Case study"
reading_minutes: 7
tags: ["css","web-performance","refactoring","design-systems","react"]
---

# Improving site performance by shipping more CSS

A post on [GitHub Engineering](https://swe.quest/sources/github.md), published 2026-09-25, 7 min read, Case study. Original: [https://github.blog/engineering/architecture-optimization/improving-site-performance-by-shipping-more-css/](https://github.blog/engineering/architecture-optimization/improving-site-performance-by-shipping-more-css/)

## Summary

GitHub migrated its Primer Design System and the github.com codebase from styled-components CSS-in-JS to CSS Modules, removing runtime styling costs on client and server. Primer components moved first, each behind a feature flag and checked against visual regression snapshots, which cut server-side render time by 55% and component initialization by 25%. A wrapper package, @primer/styled-react, kept the legacy \`sx\` prop working during the transition. About 7,760 \`sx\` props were then migrated with a VS Code plugin, codemods and later Copilot coding agents, followed by decoupling theming, and dotcom reached 100% CSS Modules in June 2026 without breakage.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [CSS](https://swe.quest/tags/css.md) (Web & mobile)
- [Web performance](https://swe.quest/tags/web-performance.md) (Web & mobile)
- [Refactoring & migrations](https://swe.quest/tags/refactoring.md) (Engineering practices)
- [Design systems](https://swe.quest/tags/design-systems.md) (Web & mobile)
- [React](https://swe.quest/tags/react.md) (Web & mobile)

## Prerequisites

- CSS-in-JS ([easy posts on CSS](https://swe.quest/tags/css.md?difficulty=easy))
- React components ([easy posts on React](https://swe.quest/tags/react.md?difficulty=easy))
- CSS Modules ([easy posts on CSS](https://swe.quest/tags/css.md?difficulty=easy))

## Keywords

Primer, CSS Modules, styled-components, sx prop, Copilot coding agent, GitHub

## Related posts

- [Styling Linear for the future with StyleX](https://swe.quest/articles/styling-linear-for-the-future-with-stylex-1042e4b9c269681c.md): Linear · 2026-08-26 · Medium · 9 min read · CSS, React, Refactoring & migrations, Web performance, Static analysis
  Linear migrated its React apps from styled-components to Meta's StyleX over more than 1,000 PRs.
- [Why We Ripped Twin out of 400+ Components](https://swe.quest/articles/why-we-ripped-twin-out-of-400-components-f0b99539dbfc3cb4.md): Railway · 2023-05-04 · Medium · 7 min read · CSS, Frontend, Refactoring & migrations, Build systems, React
  Railway replaced twin.macro with vanilla Tailwind across 400+ React components, which removed the last dependency on Babel and let the monorepo move fully to SWC.
- [StyleX: A Styling Library for CSS at Scale](https://swe.quest/articles/stylex-a-styling-library-for-css-at-scale-be53ddfe6134c8c8.md): Meta Engineering · 2025-11-11 · Medium · 10 min read · CSS, Frontend, Compilers, Design systems, Web performance
  StyleX is Meta's build-time CSS-in-JS compiler that extracts style objects into collision-free atomic CSS, replacing the earlier cx system and cutting CSS size by 80% across Facebook, Instagram, WhatsApp and others.
- [How we use Web Components at GitHub](https://swe.quest/articles/how-we-use-web-components-at-github-43357e36de1ecc50.md): GitHub Engineering · 2021-05-04 · Medium · 8 min read · Frontend, Browsers, Design systems, TypeScript, Refactoring & migrations
  GitHub moved from jQuery to native Web Components starting in 2014 and now ships dozens of custom elements such as \<include-fragment\>, \<details-dialog\> and \<relative-time\>.
- [The uphill climb of making diff lines performant](https://swe.quest/articles/the-uphill-climb-of-making-diff-lines-performant-3c1abf458c8d7ced.md): GitHub Engineering · 2026-04-03 · Medium · 10 min read · Web performance, React, Frontend, Performance engineering
  GitHub rebuilt the React diff-line components in the pull request Files changed tab after large PRs pushed the JavaScript heap past 1 GB, DOM counts above 400,000 and INP to unusable levels.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
