New

FlowConsent, our own cookie banner, is live.

Minification: plainly explained.

Minification strips whitespace and comments from code to cut file size and speed up pages. Learn how it works, the tools and best practices.

Website · Updated Nov 7, 2026

DEFINITION

Minification removes whitespace, comments and unneeded characters from HTML, CSS and JavaScript files to shrink them without changing how they behave.

CATEGORY

Website

RELATED

Core Web Vitals, CDN

Summarize this page with AI

01

What is minification?

Minification is the process of removing everything a browser does not need to run a file: whitespace, line breaks, comments and long variable names. The result is a smaller file that behaves exactly like the original. It applies mainly to HTML, CSS and JavaScript, the three file types every web page downloads before it can render.

Smaller files travel faster over the network, which improves load time and metrics such as Largest Contentful Paint. On a slow mobile connection, the difference is clearly noticeable.

02

How minification works

A minifier parses the code, then rewrites it in the most compact valid form. For CSS, it drops spaces, comments and redundant units. For JavaScript, it can also shorten local variable names (often called mangling) and remove code that can never run.

/* Before */
.button {
color: #ffffff;
margin: 0px 0px 0px 0px;
}

/* After */
.button{color:#fff;margin:0}

The minified version is unreadable for a human, which is why teams keep the readable source in their repository and only ship the minified build to production.

03

What gets minified

  • HTML: removes comments, extra spaces and optional attribute quotes.
  • CSS: merges shorthand values, removes comments and shortens colours.
  • JavaScript: strips comments, shortens identifiers and removes dead code.
  • JSON and SVG: can also be minified, since they are plain text formats.
04

Minification vs compression vs bundling

These three techniques are often confused, but they solve different problems and work best together.

TechniqueWhat it does
MinificationRewrites the source into a shorter equivalentWhere it happensBuild step
Compression (Gzip, Brotli)Encodes the file bytes more efficiently for transferWhere it happensServer or CDN
BundlingCombines several files into fewer requestsWhere it happensBuild step

Minified files still benefit from Gzip or Brotli on top, usually with a further size reduction of 60 to 80 percent.

05

Best practices and common pitfalls

  • Minify at build time, never by hand, and keep the readable source under version control.
  • Generate source maps so errors in production can be traced back to the original code.
  • Test the minified build: aggressive JavaScript mangling can break code that relies on function names.
  • Do not minify files twice, and avoid minifying third-party scripts that are already minified.
  • Combine minification with browser caching and a CDN for the best effect.
06

Minification at BeBranded

Page weight is one of the easiest performance gains, and we treat it as part of every project. On our website design and development work, we make sure CSS, JavaScript and HTML are minified, compressed and cached correctly, then measure the result against Core Web Vitals so that the speed gain is real and not only theoretical.

FAQ

Questions about Minification.

Another question?

Write to us
What is minification?
Minification is the removal of whitespace, comments and unnecessary characters from HTML, CSS and JavaScript so the files are smaller but work identically.
Does minification change how my code works?
No, a correct minifier produces code with the same behaviour. Aggressive JavaScript mangling can occasionally cause issues, so always test the minified build.
What is the difference between minification and compression?
Minification rewrites the source into a shorter form at build time, while compression such as Gzip or Brotli encodes the file for transfer at the server. They work best together.
Does minification help SEO?
Indirectly, yes. Lighter files load faster and improve Core Web Vitals, which are part of the page experience signals used by search engines.
How do I minify CSS and JavaScript?
Use a build tool or bundler such as esbuild, Terser or cssnano, or rely on your host or CDN to minify automatically. Webflow minifies its published CSS and JavaScript by default.
Should I minify HTML too?
It is worth doing, but the gain is smaller than for JavaScript and CSS. HTML is already compressed well by Gzip or Brotli.

Related

Related terms, and where to go next.

BeBranded
Development

Website maintenance: pricing, types and how to choose (2026)

Website maintenance: discover the 3 types of maintenance, real pricing by scope, red flags to watch for, and how to choose the right plan for your business.

Read the article
Webflow pricing 2026: plans, costs & what you'll really pay
Webflow

Webflow pricing 2026: plans, costs & what you'll really pay

How much does Webflow cost in 2026? Site plans, Workspace plans, add-ons, hidden costs & 3 budget scenarios. Complete guide to choosing the right plan.

Read the article
Conversion rate optimization (CRO): the complete guide 2026
Conversion

Conversion rate optimization (CRO): the complete guide 2026

What CRO is, how to calculate it, the method, tools and mistakes to avoid to turn more visitors into customers without more traffic.

Read the article

Let’s talk

Tell us what you want to build.

Thirty minutes with the people who will work on your project. You leave with a clear view of the scope, the timeline and the next steps.

What happens next

  1. 1A 30-minute callWe listen to your goals, your constraints and your context.
  2. 2A clear scopeWe map what is worth doing first, and what it takes.
  3. 3A costed proposalYou decide, with no commitment and no sales pitch.