Minification removes everything from code that a browser does not need: comments, line breaks, indentation and extra spaces. The page looks and works the same, but files are smaller and download faster. It is one of the simplest speed improvements – and PageSpeed Insights often recommends it.
Page Contents
Before and after
A small CSS rule with comments and spacing:
- Before:
/* buttons */ .btn { padding : 12px 20px ; color : #fff ; } - After:
.btn{padding:12px 20px;color:#fff}
Over a whole stylesheet, minification typically saves 10–30% of the file size.
Minification vs compression
| Minification | Compression (Gzip / Brotli) | |
|---|---|---|
| What it does | Removes unnecessary characters from the code | Encodes the file in a smaller form for transfer |
| Where | When you build or publish | On the server, every request |
| Typical saving | 10–30% | 60–80% for text files |
| Use both? | Yes | Yes |
They work together: minify first, then let the server compress.
What is safe to remove?
- Comments (except licence comments like
/*! … */) - Indentation, line breaks and extra spaces between tags
- The last semicolon in a CSS rule
What must be kept:
- Whitespace inside
<pre>and<textarea> - Code inside
<script>unless you use a proper JavaScript minifier - Spaces that separate inline words in text
Our HTML & CSS Minifier keeps these safe automatically.
JavaScript
JavaScript minifiers (such as Terser or esbuild) do more than remove spaces – they shorten variable names and remove unused code. Use them in your build process rather than by hand.
Minifying a WordPress site
- Most caching and performance plugins can minify and combine HTML, CSS and JS.
- Turn options on one at a time and test your pages – combining files sometimes breaks scripts.
- Clear the cache after changes.
Bigger speed wins
Minification is good, but images are often the heaviest part of a page. Compress your images, use modern formats (PNG vs JPG vs WebP) and check the result with our Website Checker – see how to check website speed.
FAQ
What does minify mean?
Removing unnecessary characters from code without changing how it works.
Does minifying break code?
Good minifiers are safe for HTML and CSS. Test JavaScript minification and combining carefully.
How much faster will my site be?
Minification usually saves 10–30% on code files; images and caching often make a bigger difference.
Can I un-minify code?
You can beautify it back into readable formatting, but comments that were removed are gone. Always keep the original file.
Should I minify in development?
No. Work with readable code and minify for production.
Need a website or app for your business? Talk to Techpass Master – we design and build websites and apps for clients worldwide.
