Reduce unused CSS

Trace a large stylesheet to its owner, check the states that need it, and reduce delivery without breaking the page.

A stylesheet can be essential to the website while being mostly unnecessary for one page. When a Sitepulse performance result flags unused CSS, start with the page that was tested and use DevTools to find which stylesheets it loads. The useful question is which styles this page needs before visitors can read or use it, not whether the whole stylesheet should be deleted.

Find the owner of the extra styles

Open the affected URL with browser caching disabled and locate the stylesheet in the Network panel. Its initiator and path usually tell you whether it belongs to the theme, a component, an editor or an extension. A booking widget's styles loaded on every article is a more actionable finding than a percentage labelled unused.

Record the transferred size as well as the file's uncompressed size. Removing rules can reduce both download and style-processing work, but a large percentage of a tiny file may be less consequential than a smaller percentage of a much larger file.

Exercise the page before removing rules

Use DevTools Coverage while opening menus, submitting invalid forms and changing viewport width. A rule unused during the initial screenshot may still be required by an error message, a keyboard focus state or the mobile navigation. Coverage describes the states you visited; it is not a safe deletion list.

Reduce what the page requests

  • Stop loading component styles on routes that never render that component.
  • Remove an abandoned feature's styles at their source, then rebuild the production assets.
  • Check that any CSS removal tool can recognise dynamically constructed classes. Preserve the classes generated by user content or runtime state.
  • Consider a small initial stylesheet only after removing obvious waste. Maintaining two competing copies of critical styles can create flashes and inconsistent layouts.

A common client-site repair

Suppose an events calendar contributes a large stylesheet to the homepage, contact page and blog. Move that asset out of the global template and load it from the calendar template. This fixes the cause across the site without trying to manually edit a generated, minified file. Use the platform's asset-loading mechanism so updates do not overwrite the change.

Check both appearance and the next result

Deploy the production build and verify that the public page requests the new assets. Retest the same URL in Sitepulse, then inspect a narrow screen, an open menu and a form error. If the opportunity shrinks but a state loses its styling, the optimisation is incomplete.

Treat the reported saving as a prioritisation estimate. Savings from removing unused rules and minifying the same file overlap. Continue with CSS minification or render-blocking requests when the remaining bottleneck calls for it.

Technical references