How minification works

Developers write code so that people can find their way around it: with indentation, blank lines, comments and readable names. The browser does not care. Minification strips out everything it does not need and sometimes shortens variable names too. The code works the same, it is just smaller. This applies to CSS and JavaScript files and sometimes to the HTML itself.

Minification often goes hand in hand with other tweaks: combining several files into one, compression during transfer (gzip or Brotli) and deferring scripts that are not needed straight away.

Why it matters

Every kilobyte the browser does not have to download and process shortens the time until the page appears. Minification on its own rarely makes a website dramatically faster. It is, however, a cheap and safe step that, together with caching, image optimisation and removing unnecessary plugins, adds to the overall speed. Tools such as PageSpeed Insights recommend it directly.

How to switch it on

On WordPress, most caching and optimisation plugins handle it with a single tick box. For bespoke websites and applications, minification happens automatically when a new version is built, so only the reduced files go to the server.

A real-world example

The owner of an online tea shop switched on every option in an optimisation plugin at once: minification, file combining and script deferral. The speed score improved, but product variant selection stopped working and customers could not order. After turning off combining for one WooCommerce script, everything worked and the speed gain stayed almost the same.

Common mistakes

  • Switching everything on at once without testing. Enable options one at a time and check the menu, forms and basket after each one.
  • Expecting miracles from minification when the site is slowed down by huge images or slow hosting.
  • Forgetting to clear the cache after changing settings. Visitors then keep getting the old files.