---
title: Remove Unused CSS
description: "Remove unused CSS from WordPress pages with Powered Cache Premium. Learn how used CSS is generated, the safelist, exclusions, status panel and per-page options."
url: "https://poweredcache.com/docs/remove-unused-css/"
updated: "2026-12-02"
category: File Optimization
---

# Remove Unused CSS

Most WordPress pages load far more CSS than they use, because themes and plugins ship styles for every possible page. Remove Unused CSS generates a lean stylesheet with only the rules each type of page needs, and replaces the original stylesheets with it. Pages download and process less CSS, which helps rendering speed and speed scores.

**Available in:** Powered Cache Premium, with an active license
**Where to find it:** Powered Cache → File Optimization → CSS
**Requires:** the Powered Cache CSS service must be able to load your pages from the internet.

## How Remove Unused CSS works

1. Powered Cache picks sample pages for each template: the front page, the posts page, the five latest posts of each public post type, up to 20 terms of each public taxonomy, and every post with [Generate specific UCSS](#per-page) checked.
2. The URLs go into a background queue. For each one, Powered Cache sends the page URL, your safelist and your excluded files to the Powered Cache Used CSS service.
3. The service loads the page, finds the CSS rules the page really uses, and returns them. Powered Cache minifies the result and saves it in `wp-content/cache/ucss/`.
4. When the queue is finished, the page cache of the site is cleared so pages are rebuilt with the used CSS.

On a page whose template has a used CSS file, Powered Cache removes every `<link rel="stylesheet">` tag, except stylesheets that match [Unused CSS Excluded Files](#unused-css-excluded-files), and adds the used CSS instead:

- inline, in a `<style id="powered-cache-ucss">` block, when Critical CSS is off,
- as a separate stylesheet file when [Critical CSS](/docs/critical-css/) is also on, so Critical CSS handles the first screen and the used CSS loads without blocking.

Inline `<style>` blocks stay untouched. Pages keep their original stylesheets when no used CSS file exists for their template, while a generation run is in progress, for logged-in users, and on posts with *Disable UCSS for this post*. When [Separate Mobile Cache](/docs/page-caching/#separate-mobile-cache) is on, a separate mobile version is generated.

## Set up Remove Unused CSS

1. Make sure your [license is active](/docs/install-powered-cache-premium/#activate-license) and your site is reachable from the internet.
2. Go to **Powered Cache → File Optimization**.
3. In the **CSS** group, turn on **Remove Unused CSS**.
4. Click **Save Settings**. Generation starts automatically.
5. Watch the **Used CSS** card in **CSS Optimization Status** until it shows *Healthy*.
6. Test your pages as a logged-out visitor. Open menus, popups, sliders, the cookie banner and the cart, because styles for elements that appear only after a click are the most likely to be missing.

**Default: off.** With an active license, **Apply Recommended Settings** turns on Remove Unused CSS.

## Read the status

The **Used CSS** card in **CSS Optimization Status** works like the Critical CSS card: it shows **Last run**, **Successful runs**, **Errors**, **Queued**, **HTTP** and **CSS size**, plus the last message and URL. Its state is one of *Waiting for first run*, *Processing*, *Healthy*, *Needs attention* or *Unavailable*. The meaning of each state is explained in [Read the CSS Optimization Status](/docs/critical-css/#status).

## When used CSS is regenerated

A full regeneration deletes the site's used CSS files and queues all sample pages again. It starts when you:

- turn on Remove Unused CSS and save,
- change the **Unused CSS Safelist** or **Unused CSS Excluded Files** and save,
- clear all caches with **Purge All Cache**,
- switch themes,
- click **Regenerate** in the status panel, or **Powered Cache → Generate UCSS** in the admin bar,
- run the [WP-CLI command](/docs/wp-cli-commands/#ucss).

A new run cancels the previous queue. While it runs, pages keep their original stylesheets. When you turn off Remove Unused CSS and save, Powered Cache cancels queued jobs, clears the status and deletes the generated files.

> **New in 4.0:** used CSS is generated through a background queue with a visible status card, regenerated automatically when the safelist or excluded files change, and cancelled when the feature is turned off. Built-in compatibility safeguards add safe selectors and exclusions for your theme and plugins.

## Settings

Both fields are shown when Remove Unused CSS is on and are empty by default. Saving a change starts a new generation run.

### Unused CSS Safelist

CSS selectors that must always be kept, one per line. The service only sees the page as it loads, so it can miss styles for classes that JavaScript adds later: an open mobile menu, an active tab, a popup or a validation message. Add those selectors here.

```
.menu-toggled
.my-popup-open
#cookie-banner
```

You do not need to add common WordPress, WooCommerce, page builder, form, slider and consent classes. The [CSS compatibility safeguards](/docs/css-compatibility-safeguards/) add them automatically.

### Unused CSS Excluded Files

Stylesheets that stay on the page unchanged and are left out of generation, one rule per line. Each rule is compared with the complete `<link>` tag and matches when it appears anywhere in it, so you can use part of the URL or the stylesheet ID. `*` wildcards and regular expressions work as in the other exclusion fields. Matching stylesheets are also kept out of [Combine CSS](/docs/minify-and-combine-css/#combine-css).

```
/wp-content/plugins/my-booking-widget/
my-theme/css/print-friendly.css
woocommerce-smallscreen
```

Exclude a stylesheet when its styles are needed for content that loads later, or when removing it breaks a widget. Page builder CSS files in `uploads` (Elementor, GenerateBlocks, Oxygen, Bricks, Breakdance, Beaver Builder, Spectra, Kadence, Stackable), Slider Revolution, Smart Slider 3, Dashicons and the admin bar are already excluded by the safeguards.

## Per-page options

While Remove Unused CSS is on, the **Powered Cache** panel in the post editor offers two options. Only one can be checked at a time.

- **Disable UCSS for this post:** the post keeps all its original stylesheets.
- **Generate specific UCSS:** used CSS is generated from this post alone instead of the shared file of its post type. Use it for pages with a unique layout. The post must be published. It is queued when you save the post and regenerated on every update. Full runs include up to 1,000 posts with this option.

See [Exclude a page from the cache](/docs/exclude-page-from-cache/) for all per-post options.

## WP-CLI

`wp powered-cache ucss --generate` generates used CSS in the foreground. Add `--clear` to delete existing files first and clear the page cache afterwards, and `--network-wide` on multisite. See [WP-CLI commands](/docs/wp-cli-commands/#ucss).

## Connection requirements

Unlike Critical CSS, the Used CSS service loads each page itself from its URL. It therefore must be able to reach your site:

- Pages behind a login, HTTP password protection or a maintenance page cannot be processed.
- If a firewall, security plugin or bot protection blocks unknown visitors, allow the Powered Cache service. See [Service IP addresses](/docs/service-ip-addresses/).
- Generation runs with WordPress's background scheduler. If WP-Cron is disabled, make sure a server cron job calls `wp-cron.php`.

## Troubleshooting

### Some elements lose their styles

1. Find the class of the element in the browser developer tools (right-click → **Inspect**).
2. Add the selector to **Unused CSS Safelist**, or add the stylesheet that contains it to **Unused CSS Excluded Files**.
3. Save, and wait for the new run to finish.

For a single affected page, use *Disable UCSS for this post*. See [Broken layout after optimization](/docs/broken-layout-after-optimization/).

### Nothing is generated, or the status says Needs attention

Check the HTTP code and message on the Used CSS card, and that the service can reach your site. Each message is explained in [CSS generation issues](/docs/css-generation-issues/).

## For developers

Filters: `powered_cache_ucss_safelist`, `powered_cache_ucss_excluded`, `powered_cache_ucss_source_urls`, `powered_cache_ucss_file_lookup`, `powered_cache_ucss_inline_output` and `powered_cache_ucss_frontend_disable`. See the [hooks reference](/docs/hooks-reference/).

## Related docs

- [Critical CSS](/docs/critical-css/)
- [CSS compatibility safeguards](/docs/css-compatibility-safeguards/)
- [CSS generation issues](/docs/css-generation-issues/)
- [Service IP addresses](/docs/service-ip-addresses/)
- [WP-CLI commands](/docs/wp-cli-commands/#ucss)
