Skip to main content

A module filter.

Prioritize critical CSS

CSS

Inlines above-the-fold CSS and loads the rest after first paint.

Filter rewrite_css,flatten_css_imports,inline_import_to_link,prioritize_critical_css · Filter docs · Read the full guide

Both frames render identically — that's the goal. The win is in the bytes and requests below, not the look. They're served live by the mod_pagespeed module on demo-httpd-1.1.modpagespeed.com; the optimized frame applies only this filter. Right after a cache purge it may briefly match the original while the worker rewrites it — reload to see the result. This filter is beacon-driven: mod_pagespeed instruments the page, a real browser reports back, then it serves the optimized form and re-measures every few minutes — so the optimized frame can take a reload, or briefly revert to the original, before it reflects the change.

Measured impact

Measured on the Prioritize critical CSS demo page, original against optimized: the total weight (HTML plus the files it loads) falls from 6.2 KB to 5.9 KB, 4% smaller.

Total bytes

original
6,341 B
optimized
6,089 B

−252 B −4% in size

Measured on the demo stack, November 2026.

What changed in the source

The page's HTML, before and after this filter. Red lines are removed, green lines are added.

                
                  
… 1 unchanged line …
<html>
<head>
<title>prioritize_critical_css example</title>
- <link rel="stylesheet" type="text/css" href="styles/blue.css">
- <link rel="stylesheet" type="text/css" href="styles/big.css">
- <style>
- @import url(styles/all_using_imports.css);
- </style>
- <link rel="stylesheet" href="styles/rewrite_css_images.css" media="all">
+ <link rel="stylesheet" type="text/css" href="styles/A.blue.css.pagespeed.cf.JgQj7wAyqo.css">
+ <link rel="stylesheet" type="text/css" href="styles/A.big.css.pagespeed.cf.pSXIseppZs.css">
+ <link rel="stylesheet" href="styles/A.all_using_imports.css.pagespeed.cf.UWCtVOe4cC.css"/>
+ <link rel="stylesheet" href="styles/A.rewrite_css_images.css.pagespeed.cf.JWIi61uu6v.css" media="all">
</head>
<body>
<div class="foo" style="display:inline-block;"></div>

Run this on your own site

This is one of 49 filters the mod_pagespeed module applies in place — self-hosted on Apache, nginx, and IIS. Install and run it: it optimizes right away and adds the optimized response headers shown above. Open source under the Apache License 2.0 — free in development and in production.

Search