Critical CSS
Definition
A normal page links one stylesheet, and nothing is painted until that file is downloaded and parsed. Critical CSS splits the job: the rules styling everything visible without scrolling go straight into a style tag in the head, and the remainder is loaded in a way that does not block. The inline block usually lands somewhere between 4 and 14 kilobytes, small enough to fit inside the first network round trip, which is where the upper number comes from. What counts as critical depends on the viewport, so the set is normally generated at a mobile width and reused. Tools such as Critical and Penthouse produce it by loading the page and recording which rules apply above the fold.
Why It Matters
On a static page this is often the largest single win available, because the stylesheet is usually the only thing standing between the HTML and the first paint. Removing that one blocking request can take several hundred milliseconds off Largest Contentful Paint on a mobile connection, and the HTML grows by a few kilobytes the visitor was going to download anyway. The risk sits on the other side: if the inline set is wrong, the visitor gets a flash of half-styled content and then a jump when the real stylesheet lands, which looks cheap and registers as layout shift as well.
How It Works
Generating it is mechanical — load the page at a chosen width, walk the rendered tree, keep every rule matching something in the first screenful and discard the rest. That output goes inside a style tag in the head. The full stylesheet then loads without blocking, usually through the preload pattern: a link with rel="preload" and as="style", plus an onload that flips rel to stylesheet, and a noscript copy behind it for browsers with scripting off. Because the critical block is inlined it cannot be cached separately from the HTML, so it has to be regenerated whenever the design changes or it quietly goes stale. Keep it small: past roughly 14 kilobytes you are paying the cost on every page load without buying back a round trip.
Real-World Example
A twelve-page handbook published as static files at docs-handbook.99helpers.site shares one 90 kilobyte stylesheet. Inlining about 6 kilobytes of header, navigation and body type into each page and deferring the rest cuts first paint on a 4G connection from roughly 1.9 seconds to under one. The full stylesheet still arrives and still caches, so every page after the first behaves exactly as it did before.
Common Mistakes
- ✕Inlining the whole stylesheet — the CSS can no longer be cached on its own, so every visit downloads all of it again inside the HTML
- ✕Generating it once and forgetting it — after a redesign the inline block styles elements that no longer exist and misses the ones that do
- ✕Generating at a desktop viewport — the first screen on a phone needs a different set of rules, and phones are where the delay actually hurts
Related Terms
Render-Blocking Resource
A render-blocking resource is a file the browser has to download and process before it can show anything at all. Stylesheets and ordinary script tags in the head block; almost nothing else does.
Stylesheet
A stylesheet is the set of CSS rules that tells the browser how a page should look. It is usually a separate .css file linked from the head, though it can also sit in a style element inside the HTML itself.
Cumulative Layout Shift
Cumulative Layout Shift measures how much the content of a page moves about while it is loading. A good score is 0.1 or below; anything above 0.25 counts as poor.
Largest Contentful Paint
Largest Contentful Paint, or LCP, marks the moment the biggest visible element in the viewport has finished rendering. It is the closest single number to the question a visitor actually asks: when did this page look like it had loaded?
Minification
Minification strips everything from CSS, JavaScript and HTML that a browser does not need — spaces, line breaks, comments, long variable names — leaving smaller files that behave identically.
Put a file online in seconds
Drop in a document, an image, a page or a whole static website and share the link — free, with no build step and no server to set up.
Host a file free →