Critical CSS

Inlining just the styles the first screen needs, then loading the rest of the stylesheet later so nothing blocks the first paint.

above the fold stylesinline the top-of-page CSScritical path csscritcssput the styles in the head instead of a filethe stylesheet blocks renderingonly ship the CSS the first screen needsunstyled flash while css loads

See it

Live demo coming soon

What it is

A linked stylesheet whose media condition matches the current device is render blocking: the browser refuses to paint anything until it downloads and parses the whole file, even the rules for your footer. (A sheet with media='print', or a media query that does not match, gets fetched at low priority and never holds the paint. That is exactly the trick behind the async load below.) Critical CSS splits that in two. The rules needed to draw the first screen go inline in a style tag in the head (zero extra round trips), and the full stylesheet loads asynchronously and takes over once it lands.

Nobody writes this by hand. Tools render the page at a target viewport, record which selectors actually match visible elements, and emit the subset at build time: Addy Osmani's Critical, and beasties (formerly critters), which Angular and several meta frameworks ship by default. The async load is usually a link with media='print' flipped to 'all' on load, or rel='preload' as='style' with an onload swap. It pays off most on content-heavy first visits where FCP and LCP are dominated by one fat stylesheet.

Two ways it bites. Inlined CSS is not cached, so it re-ships on every page load: keep it small, roughly a few kilobytes, or you trade render blocking for a heavier HTML document. And it goes stale the moment someone edits a component, so it has to be regenerated in the build, never committed by hand. If your CSS is already small (a trimmed Tailwind build, for example) this is effort better spent elsewhere.

Ask AI for it

Add a critical CSS step to this build. Extract the styles required to render the above-the-fold markup at a 360x640 and a 1280x800 viewport, inline that subset in a style tag in the head, and load the full stylesheet non-blockingly with link rel='preload' as='style' plus an onload swap to rel='stylesheet' and a noscript fallback. Generate it per template at build time (Critical or beasties), keep the inlined payload under 10kb, and report First Contentful Paint before and after.

You might have meant

render blocking resourcecritical rendering pathfirst contentful paintunused javascript csslargest contentful paint