
Critical CSS: Extract, Minify and Inline for LCP
Extract above-the-fold CSS, minify the block, inline it in the head, then load the rest async. How it helps LCP without shipping all styles first.
Why CSS blocks your LCP
Every external stylesheet is render-blocking. The browser delays painting until it has downloaded and parsed the entire CSS file, even when only a handful of rules apply to above-the-fold content. On a landing page with 180 KB of styles, Largest Contentful Paint (LCP) can exceed 3 seconds on a slow mobile connection. The critical CSS strategy extracts the above-the-fold styles, minifies them, inlines them in the `<head>` and loads the rest asynchronously. To shrink the extracted block, the FastMinify online CSS minifier shows the savings. This guide covers the full workflow of extraction, minification, HTML inlining and measurement. It complements our complete CSS minification guide and the article on Core Web Vitals and minification.
Impact on LCP
Illustrative numbers for a page with Bootstrap and a custom theme, as Lighthouse reports them on simulated mobile 4G. Your own results will differ:

Before optimization
- LCP
- 3.8s
- Google Score
- 62/100
- File size
- 180 KB blocking CSS
- Load time
- 2.1s FCP
After optimization
- LCP
- 1.9s
- Google Score
- 91/100
- File size
- 4 KB inline + 176 KB async
- Load time
- 0.9s FCP
Improvements
The technique delivers the most value in these contexts:
Measure impact on your Core Web Vitals
Verify that critical CSS improves field LCP as well as the synthetic Lighthouse score. Cross lab and field data:
Compare before/after on a representative page sample. See our Core Web Vitals and fast-site SEO articles for Google thresholds and ranking impact.
Inline critical CSS in HTML
Combine inline CSS for the critical rules with deferred loading for the rest. This pattern works with most stacks. The noscript fallback keeps the page styled when JavaScript is off:
Before
After
Integration in modern frameworks
In Next.js 15, the experimental `optimizeCss` option inlines critical CSS with Critters, a package you install yourself. It only processes pages rendered by the Pages Router, so for App Router pages run `critical` on the built output:
Pages Router
In `next.config.js`, set `experimental: { optimizeCss: true }`. Critters then inlines the critical CSS of each Pages Router page in the HTML it serves.
Manual build
Run `critical` after the build on `out/index.html` (static export) or on snapshots of server-rendered pages.
Nuxt has a maintained module for this. For Gatsby, run `critical` after the build:
Nuxt
The `@nuxtjs/critters` module injects critical CSS into prerendered pages.
Gatsby
Run `critical` on the HTML files in `public/` after `gatsby build`.
Best practices and common pitfalls
Before you ship to production, check this list:
These issues often appear after a first Critical CSS implementation:
What is Critical CSS?
Critical CSS is the minimal set of rules needed to display above-the-fold content correctly in the initial viewport: header, hero, base typography, main layout. Every external `<link rel="stylesheet">` blocks rendering while the browser builds the CSSOM. Minification reduces size; Critical CSS reduces blocking by delivering those rules inline without a network round trip.
The most common transformation on a static or SSR page:
Before
After
Minify your Critical CSS with FastMinify
After extraction with `critical` or Penthouse, paste the CSS into FastMinify's online CSS minifier to get the most compact version before inlining. If you serve static pages, minify the final HTML with our online HTML minifier as well.

1. Extract
Generate `critical.css` with critical or Penthouse on your production build, not on the dev build, because class names may differ.
2. Minify
Paste the extracted CSS into FastMinify and compare the size before and after. Aim for under 14 KB inline when possible.
3. Inline it and defer the rest
Insert the minified CSS in a `<style>` tag in the `<head>`. Load the full stylesheet asynchronously with preload or the `media="print"` trick.
Extract critical CSS programmatically
The `critical` package is the standard way to generate critical CSS from a URL or HTML file. Configure viewport dimensions (mobile + desktop) to cover real-world cases:
Configuration
Usage
Generated CSS still contains whitespace and comments. Run it through CSSO or our online tool before inlining. The CSS minification guide covers advanced options. Savings are often 20–40% on the extracted block, the range our CSS tool documentation gives.
Configuration
Usage
Conclusion
Critical CSS can improve LCP without rewriting your stack. Extract the above-the-fold styles, minify them, inline them in the HTML and defer the rest. Combine it with systematic CSS minification, Brotli compression and lean HTML.
Minify your critical CSS now
Related Articles

Paste a token and a JWKS to check an RS256, ES256 or HS256 signature in your browser. How kid picks the key, measured errors and the claims to check.

HTTP/2 and HTTP/3 change how files travel, not how big they are. Measured sizes, compile times and bundling tests show what minification still saves.

Convert a Unix epoch to a readable date and back, tell seconds from milliseconds, and avoid time zone, JWT and clock change traps, all in your browser.