Minifying CSS in WordPress
In WordPress you rarely minify by hand: a caching plugin does it on every request. That is the right default, but it is also where most “my site broke after I turned on optimisation” stories come from. Here is what each option actually does and when to switch it off.
Where the CSS on a WordPress page comes from
A typical page loads CSS from four places at once: the theme stylesheet, the block editor styles that WordPress itself adds, one file per active plugin, and whatever the page builder injects. Twenty separate stylesheets on one page is normal rather than exceptional.
That matters because minification is not your biggest problem there. Twenty requests, each one render-blocking, costs far more than the whitespace inside them. Combining comes before compressing.
What the plugins do
Caching plugins with an optimisation tab
WP Rocket, LiteSpeed Cache, W3 Total Cache and WP Super Cache (with a helper) all offer “minify CSS” and usually “combine CSS” next to it. They run a minifier over your files on first request and cache the result. This is the easiest route and the one to use unless you have a reason not to.
Dedicated optimisation plugins
Autoptimize and Perfmatters focus on exactly this: combining, minifying, inlining critical CSS and deferring the rest. Autoptimize is free and well established; Perfmatters is paid and leans more on switching off what you do not need, which is usually the bigger win.
Your host
A growing number of hosts do this at server level, outside WordPress entirely. If yours does, turning on a plugin that does the same thing gets you two minifiers fighting over the same file. Check the host panel first.
When it breaks, and what to do
The failure is nearly always one of three things:
- Combining, not minifying. Two stylesheets that each worked separately now fight over the cascade, because combining changes the order rules are applied in. Switch off “combine” and keep “minify”; nine times out of ten the problem is gone.
- A plugin that writes CSS inline at runtime — page builders do this constantly — and the optimiser caches a version from before those styles existed. Exclude that plugin\'s handle rather than switching everything off.
- A genuinely unsafe minifier that rewrote a
contentvalue or dropped a space in a selector. Rare, but silent and maddening. Our minifier test shows which constructs are at risk and lets you check your own output.
Debug it in that order. Clear every cache between attempts, including the browser\'s and your CDN\'s, or you will be chasing a result from ten minutes ago.
When to do it by hand instead
Use a plugin for the site\'s own output. Use a tool like the CSS compressor on this site when:
- You are writing a child theme stylesheet and want to ship it minified, without an extra plugin running on every request.
- You are building a plugin or theme for someone else and the minified file is part of what you deliver.
- You want to know how much a specific file is actually costing you before deciding whether to optimise at all.
- You need to read a minified stylesheet that came with a theme — that is the beautifier.
The order that actually helps
- Switch off plugins you are not using. Every one of them stops loading its CSS.
- Stop loading the rest where it is not needed (Perfmatters, or
wp_dequeue_stylein your own code). - Combine what is left, then minify it.
- Make sure your host serves it with brotli or gzip and a long cache header.
- Only then worry about critical CSS — see CSS optimization for speed.
Steps one and two usually beat three and four combined, and neither of them can break your layout.
Should I use both a caching plugin and Autoptimize?
Only if the caching plugin does not already minify. Two tools minifying the same file at best wastes work and at worst produces a file neither of them expected. Pick one and switch the other's CSS options off.
Does minifying CSS speed up WordPress noticeably?
On its own, rarely. Reducing the number of stylesheets and the number of plugins does. Treat minification as the finishing touch, not the fix.
My site broke. How do I undo it?
Switch off the optimisation option, clear every cache (plugin, browser, CDN), and reload with a hard refresh. If the site is unreachable, rename the plugin folder over FTP or SFTP; WordPress then deactivates it by itself.
Other tools on this site
Read more
- What is CSS minification? – What a minifier removes and what it saves
- CSS optimization for speed – Beyond minification: critical CSS and Core Web Vitals
- What breaks a CSS minifier? – Live test of the constructs minifiers get wrong
- Frequently asked questions – Answers to the questions we get most
- Useful links – Reference material on CSS and speed
- About this site – Who makes this and how to reach us