Prioritize critical CSS
CSSInlines 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
A mod_pagespeed 1.1 filter. ModPageSpeed 2.0 applies it as part of one always-on pipeline, not as a separate switch.
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 mod_pagespeed 1.1 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
This filter changes how the page is structured or delivered, not its size — so there's no byte or request reduction to chart. The change shows in the source diff below.
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>