CSS Performance Overview
CSS performance is easy to underrate because CSS files are usually small compared to JavaScript bundles or images. But CSS sits in a uniquely powerful position in the browser's rendering pipeline: it's render-blocking by default, it can force expensive layout recalculations, and the wrong property animated in the wrong way can make an otherwise fast page feel janky. "Just make the file smaller" is only a small part of the real picture — this section covers the mechanisms that actually determine how fast a page feels once CSS is involved.
What this section covers
Topic | What it addresses |
|---|---|
Inlining just enough CSS to render above-the-fold content immediately, deferring the rest | |
Which CSS changes are cheap (paint-only) vs. expensive (full layout recalculation) | |
Hinting the browser to prepare an optimization ahead of a change, and the risk of overusing it | |
Isolating an element's rendering so changes inside it don't ripple out to the rest of the page | |
Skipping rendering work for off-screen content entirely until it's about to be needed | |
How much (or how little) selector complexity actually matters in modern engines | |
Controlling how and when web fonts swap in, avoiding invisible text and layout shift |
Why CSS performance goes beyond file size
A handful of distinct mechanisms are worth keeping in mind, each covered in more depth on its own page:
<head>. A large or slow-loading CSS file delays first paint for the entire page, not just the parts that file actually styles.transform, opacity) can be animated entirely on the GPU's compositor thread, without touching layout or paint at all — which is why they're dramatically smoother to animate than properties like width or top.will-change and contain exist, and contain is itself the foundation that content-visibility builds on. Reading them in the table order above will make each subsequent page click faster.