SEO

Minification

Also called minify, minified CSS, minified JavaScript

Removing spaces, comments and unneeded characters from CSS, JavaScript and HTML files so they are smaller and load faster.

Quick facts: Minification

Category
SEO
Also called
minify, minified CSS, minified JavaScript
Level
Beginner
Affects
File size, page load time, Core Web Vitals, crawl efficiency
Where to see it
PageSpeed Insights, Lighthouse, Chrome DevTools Network panel, WordPress performance plugins
In this article4
  1. How minification works
  2. Why it matters
  3. Common mistakes
  4. How to act on it

Minification is the process of shrinking code files, mainly CSS, JavaScript and HTML, by removing everything a browser does not need to run them: spaces, line breaks, comments and long variable names. The file works exactly the same but downloads faster.

How minification works

Developers write code to be readable by people, with indentation, comments explaining what each part does and descriptive names. Browsers do not need any of that. A minifier rewrites the file in its most compact form. A CSS rule spread over six lines with comments becomes a single line; in JavaScript, a variable called basketTotalIncludingVat may become a.

The savings depend on how the code was written. Heavily commented, hand-written files shrink noticeably, while libraries that already ship minified gain nothing. Minification is different from compression: compression with Gzip or Brotli happens on the server as files are sent and is undone by the browser, while minification changes the file itself. The two work best together.

It is usually handled automatically, by a build tool such as esbuild, Terser or cssnano on a custom site, by a performance plugin on WordPress, or by the platform itself on Shopify and most hosted builders. Do not assume your content delivery network is doing it: Cloudflare, for example, retired its Auto Minify setting in 2024, so sites that relied on it are now serving unminified files unless something else took over.

Why it matters

Smaller files arrive sooner, and CSS and JavaScript often block the page from displaying until they have loaded. On a mobile connection on a busy train, a few hundred kilobytes saved across a page can be the difference between a visitor seeing your content quickly and giving up.

Speed feeds into Core Web Vitals, particularly Largest Contentful Paint, and into how many visitors stay to enquire or buy. Minification alone rarely transforms a slow site, but it is cheap, low risk when tested, and easy to confirm in PageSpeed Insights.

Common mistakes

  • Expecting it to fix a slow site. Oversized images, too many third-party scripts and slow hosting usually cost far more than unminified code.
  • Combining and minifying everything blindly. Aggressive plugin settings can break menus, sliders, forms or checkout scripts. Test on a staging copy first.
  • Minifying twice. A plugin, a theme and a CDN all minifying the same files can cause errors that are hard to trace.
  • Editing the minified file. Changes should be made in the readable source and the file rebuilt, or they will be lost at the next update.
  • Forgetting to clear caches. After switching minification on, old cached files can mask the change or cause mismatched styling.

How to act on it

Run your key pages through PageSpeed Insights or Lighthouse and check the performance diagnostics for unminified CSS or JavaScript, which name the files and the potential savings. In Chrome DevTools, a file whose preview shows readable indentation and comments has not been minified. If the files belong to your theme or plugins, switch on minification in one place only, usually your performance plugin or build process.

Test the pages that make you money after every change: the contact form, the booking flow, the basket and checkout. Then work on the bigger wins such as images, unused scripts and render-blocking resources. Prioritising speed fixes by impact is part of what I do in technical SEO.

Do and do not

Do

  • Minify CSS and JavaScript in one place only
  • Test forms and checkout after changes
  • Combine minification with Gzip or Brotli compression

Do not

  • Expect minification alone to fix a slow site
  • Edit minified files directly
  • Stack minification in plugin, theme and CDN

Questions people ask about this

Does minification improve SEO?

Indirectly. Smaller files can make pages load faster, which supports Core Web Vitals and keeps more visitors on the page. On its own it is a small gain, so treat it as one part of speed work rather than a ranking fix.

Can minification break my website?

Minification on its own is usually safe, but combining files or aggressive settings in some plugins can break scripts, particularly menus, sliders and checkout. Test on a staging copy, change one setting at a time, and clear all caches before checking the result.

Is minification the same as compression?

No. Minification removes unnecessary characters from the file itself, while compression such as Gzip or Brotli shrinks files as the server sends them and the browser unpacks them. Use both; they add up.

Related terms

Found this useful?

Share it, or ask an AI to summarise it

Back to the glossary

Knowing the term is the easy part

Applying it to your own site and budget is the work. Book a call and I will tell you what actually applies to you.