Feedback

Reduce Unused CSS

A single global stylesheet shared across an entire site is convenient to maintain, but it usually means every page downloads CSS rules for components that page doesn't even contain. This audit measures exactly how much of that is happening.

What it means

Lighthouse runs the same coverage analysis it uses for unused JavaScript against your stylesheets: it loads the page, records which CSS rules were actually applied to something on screen, and flags the rest as unused. A framework-wide stylesheet with every component's styles, loaded on a page that renders three of those components, is the classic case.

Why it matters

Unlike most JavaScript, a <link rel="stylesheet"> is render-blocking by default (see eliminating render-blocking resources): the browser won't paint anything until it has parsed the full stylesheet, whether or not most of those rules apply to the current page. So unused CSS isn't just extra bytes, it's extra bytes directly on the critical path to first paint.

How to fix it

// postcss.config.js
module.exports = {
  plugins: [require('@fullhuman/postcss-purgecss')({
    content: ['./src/**/*.html', './src/**/*.jsx'],
  })],
};
// tailwind.config.js
module.exports = {
  content: ['./src/**/*.{html,js,jsx,php}'],
};

How to verify

Re-test the page; the unused-css-rules audit should report a much smaller number of wasted bytes. To check a specific page manually, open DevTools' Coverage panel and reload. The CSS section shows the exact percentage of each stylesheet that was used.

Test your site

Run a free scan to see whether this applies to your pages, on mobile and desktop, with lab and field data side by side.

Run a free test

Related audits