Skip to content
← All notes
cssperformancearchitecture
4 min read

Partitioning a CSS monolith without breaking the budget

How S3 killed style.css, moved to design tokens, and kept first-paint CSS under 12 KiB gzip.

The old style.css was a single file mixing tokens, layout, features and one-off hacks. Every route paid for every pixel.

The plan

  1. Extract tokens into tokens.css (the only place hex lives).
  2. Ship feature CSS with the feature (mirror.css, lab.css, diorama.css).
  3. Ban hex literals outside tokens with ESLint + a check-hex script in lint.

What broke

Tailwind was still in the lockfile after removal from config. npm install regenerated a clean lock with zero Tailwind packages. Orphan selectors were caught by a new gate before they shipped.

Result

First-paint CSS: 9.95 KiB gzip / 12 KiB budget. No monolith, no silent color drift.

Leer en español