Course contentsShow
← React
Lesson 1933 of 2,39644. Styling ApproachesFree lesson

What Zero-Runtime Means

Understanding how vanilla-extract extracts styles at build time, shipping only CSS without JavaScript runtime overhead.

What Zero-Runtime Means

You'll learn what distinguishes zero-runtime CSS solutions from traditional CSS-in-JS libraries and why this matters for performance.

The Core Idea

Zero-runtime means your styling solution extracts all CSS at build time and ships static .css files to the browser—no JavaScript executes at runtime to generate, inject, or manage styles. This is fundamentally different from libraries like styled-components or Emotion, which generate and inject CSS dynamically while your React app runs in the user's browser.

Think of it like this: traditional CSS-in-JS is a chef preparing your meal to order (runtime work), while zero-runtime is meal-prep where everything's cooked in advance (build time work). Users get the finished product instantly.

How It Works

Libraries like vanilla-extract analyze your style code during your build process (Vite, webpack, etc.). They:

  1. Parse your TypeScript/JavaScript style definitions
  2. Generate optimized CSS files
  3. Replace your style references with simple class name strings
  4. Output static CSS that's loaded like any traditional stylesheet

What ships to the browser:

  • Plain CSS files (cacheable, fast)
  • Class name references (tiny strings)

What does NOT ship:

  • The styling library itself
  • Runtime style generation logic
  • Theme serialization code

The Performance Win

Zero JavaScript overhead means faster initial page loads, no style injection blocking rendering, and predictable performance regardless of how many styled components you render. The browser handles CSS natively, as it was designed to.

Key Takeaway: Zero-runtime CSS solutions like vanilla-extract perform all styling work at build time, shipping only static CSS files without any JavaScript runtime cost—eliminating the performance overhead of traditional CSS-in-JS libraries.