Zum Inhalt springen
Core Web Vitals specialists
All Articles Performance

Critical CSS: Visible Area Loaded in Milliseconds

13 min read
Critical CSSCSSLCPFrontendAbove the Fold

CSS is a render-blocking resource: the browser renders not a single pixel until CSS files are fully loaded and parsed. For a typical online shop with 200-400 KB CSS (uncompressed), this means the user stares at a white screen while the browser downloads stylesheets that are 85-95% irrelevant for the currently visible area (Source: HTTP Archive, 2025). Critical CSS solves this problem by embedding only the CSS rules needed for the visible area (above the fold) inline in the HTML head. The rest is loaded asynchronously. The result: the visible area renders in milliseconds instead of seconds, the LCP score typically improves by 40-60% and First Contentful Paint drops below one second (project experience). This article explains the entire process from extraction through implementation to automation.

Critical CSS: Above-the-Fold Rendering PipelineWithout Critical CSSHTML loaded - waiting for CSS...Render-Blocking: styles.css (180 KB)Render-Blocking: vendor.css (95 KB)Blocked 1.8sLCP: 3.2sFCP: 2.4sWhite screen until CSS fully loadedWith Critical CSSInline Critical CSS (8 KB in HTML Head)Header, Hero, Navigation, Typography, LayoutInstant rendering of visible areaLoad remaining CSS async: media=print, onload=this.media=allLCP: 1.4sFCP: 0.6sInstantly visible content, rest loads in backgroundResult: 56% Faster LCP | 75% Faster FCP1. ExtractIdentify critical-path CSSfor the viewportPenthouse, Critical, Critters2. InlineEmbed critical CSS as styletag in the HTML headMax. 14 KB (TCP Window)3. Defer RestLoad full CSS asyncafter initial renderingmedia=print + onload TrickCommon Pitfalls to AvoidToo much CSS inlinedWeb fonts forgottenFOUC not testedNo fallback styling

Why CSS Blocks Rendering

To understand why Critical CSS is so effective, you need to understand the browser's rendering process. When the browser receives an HTML document, it builds the DOM tree (Document Object Model). In parallel, it loads referenced CSS files and builds the CSSOM tree (CSS Object Model). Only when both trees are fully constructed can the browser create the Render Tree -- the combination of DOM and CSSOM that determines which elements are visible and how they are displayed. Until the CSSOM is complete, the browser renders nothing.

This behavior is intentional: the browser waits for CSS to prevent a Flash of Unstyled Content (FOUC) -- the brief flash of unstyled HTML before CSS is loaded. Without this blocking, the user would first see raw text without layout, colors or typography that then suddenly snaps into the styled design. This is a poor user experience that the browser prevents through render-blocking.

The problem arises when CSS files are large and take long to load. A typical Shopware installation loads 150-300 KB CSS (uncompressed), a WordPress theme with multiple plugins 200-500 KB. Even with Brotli compression to 40-80 KB, the download on a 3G mobile connection takes 300-800 milliseconds -- time during which the user sees a white screen. Critical CSS reduces render-blocking time to the duration the browser needs to parse 5-14 KB of inline CSS: typically under 50 milliseconds.

What Exactly Is Critical CSS?

Critical CSS (also called Critical-Path CSS or Above-the-Fold CSS) is the minimal subset of all CSS rules on a page needed for rendering the visible area (viewport). This includes all CSS rules applied to elements visible on initial page load: header, navigation, hero area, first text sections and their layout, typography, colors and spacing.

Extracting Critical CSS is conceptually simple: determine which HTML elements are visible in the initial viewport, collect all CSS rules applied to those elements (including media queries, pseudo-elements and inherited styles) and remove everything else. In practice, this process is complex because it depends on the viewport (mobile vs. desktop), dynamic content (JavaScript-rendered elements) and CSS specificities (a rule for an element below the fold can affect styles for an element above the fold).

The ideal Critical CSS size is under 14 KB (compressed). This value is not arbitrary: the TCP protocol uses an Initial Congestion Window of typically 10 TCP segments (approximately 14,600 bytes). Everything that fits in this first window is transmitted in a single network roundtrip. If the HTML document including Critical CSS stays under 14 KB, the browser can render the visible area after the first roundtrip -- without waiting for additional data packets (Source: Google, 2024).

Extracting Critical CSS: Tools and Methods

Critical CSS extraction can be done manually or automated. Manual extraction is practical for small websites with few template types: the Chrome DevTools Coverage function (Ctrl+Shift+P, 'Coverage') shows for each CSS file which rules are used on the current page and which are not. Unused rules are removed, used rules for the above-the-fold area are identified and extracted into a separate Critical CSS file.

For larger websites and automated workflows, specialized tools exist. Penthouse (Node.js) opens the page in a headless Chrome, determines the viewport and extracts all CSS rules for visible elements. Critical (npm package by Addy Osmani) builds on Penthouse and additionally offers the ability to inline Critical CSS directly into the HTML and load the remaining CSS asynchronously. Critters (Google, Webpack plugin) takes a different approach: instead of rendering the page, it statically analyzes CSS selectors and identifies which elements are present in the HTML.

Each tool has strengths and weaknesses. Penthouse and Critical deliver the most precise results because they actually render the page -- they account for JavaScript-generated content, media queries and dynamic styles. The downside: they require a headless browser and are slower (1-5 seconds per page). Critters is significantly faster but cannot detect JavaScript-generated elements. For most projects we recommend Critical as a build-time tool integrated into the frontend optimization process.

Identify

Chrome DevTools Coverage function shows unused CSS rules. Typical: 85-95 percent of loaded CSS is not used on the current page.

Extract

Specialized tools like Penthouse or Critical analyze the viewport and extract only the CSS rules relevant for visible elements.

Inline Embed

Critical CSS is embedded as a style tag in the HTML head. Target: under 14 KB compressed to stay within the first TCP Congestion Window.

Load Rest Async

The complete CSS is loaded asynchronously with media=print and onload handler, without blocking initial rendering.

Automate

Build process integration via Webpack, Vite or Gulp automatically generates Critical CSS for each page type on every deployment.

Validate

Lighthouse score, LCP measurement and visual comparison ensure Critical CSS works correctly and no FOUC occurs.

Inline vs. External: The Right Embedding Strategy

Critical CSS can be embedded in two ways: as an inline