Full answer
A stylesheet loaded with <link rel="stylesheet"> blocks rendering. The browser will not paint the page until it has downloaded and parsed it, because it needs the styles to paint correctly. A large stylesheet on a slow network delays the first paint.
The critical CSS strategy splits the CSS in two parts.
- Critical CSS: the rules needed to draw what is visible without scrolling (the layout, header, fonts and hero). It is small and goes into a
styleelement in thehead, so the first paint needs no extra request. - The rest of the CSS: loaded without blocking. A common pattern is
<link rel="stylesheet" href="rest.css" media="print" onload="this.media='all'">. A stylesheet with a media type that does not match is downloaded at low priority and does not block. When it loads, the script switches the media toalland it applies. Add a<noscript>link as a fallback for users with scripts off. Another pattern isrel="preload" as="style"with a switch inonload.
Costs and risks:
- The critical part must be kept in step with the pages. Tools can extract it at build time, but the result depends on the viewport sizes you choose. Missing rules cause a flash of unstyled content, and layout shifts when the rest loads.
- The inline part is not cached by itself, and is sent again with every page. Keep it small, about the size of a few network packets.
- The same rules are sent twice (inline and in the full file) unless the build removes them.
- With HTTP/2 and good caching, and with small sheets, the gain can be small. Measure with real pages and a slow network before and after.
The hero is styled at once by the inline rules. The paragraph gets its colour only after the second stylesheet has loaded and its media was switched to all.
Test with network throttling, and check that the page does not jump when the rest of the styles arrive.
<style>
body { margin: 0; font: 16px sans-serif; }
.hero { height: 60px; background: #cde; }
</style>
<link rel="stylesheet" href="/css/rest.css" media="print" onload="this.media='all'" id="rest">
<noscript><link rel="stylesheet" href="/css/rest.css"></noscript>
<div class="hero">Hero</div>
<p class="late" id="p">Styled by the late stylesheet</p>The stylesheet file is a small placeholder served by a local test server. The check read the media value and the colour after the load. Real network timing was not measured. Run in Chrome 156 (headless) as a page; the snippet is wrapped in a minimal HTML document with doctype, charset and viewport meta tag. Two full runs gave identical results, and the measured values in the answer come from them.
Key points
- Normal stylesheets block rendering.
- Inline the small critical part in the head.
- Load the rest with media="print" and an onload switch, plus noscript.
- Keep critical CSS in step with the pages.
- Measure with a slow network before and after.
Common mistakes
- Inlining the whole stylesheet, which makes every page heavy and uncached.
- Extracting critical CSS for one viewport size and breaking others.
- Forgetting the noscript fallback.
Follow-ups
- Why does a stylesheet with media="print" not block rendering?
- How do you stop a layout shift when the late CSS loads?
Tips
- Explain why CSS blocks rendering first, then the split.
- Say that the benefit must be measured, not assumed.