CSScompressor Nederlands

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:

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:

The order that actually helps

  1. Switch off plugins you are not using. Every one of them stops loading its CSS.
  2. Stop loading the rest where it is not needed (Perfmatters, or wp_dequeue_style in your own code).
  3. Combine what is left, then minify it.
  4. Make sure your host serves it with brotli or gzip and a long cache header.
  5. 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