Minification is the process of reducing source code to its smallest equivalent form by stripping whitespace, comments and line breaks and often shortening variable names, without changing what the code does.
Why it matters
Smaller files download and parse faster, which improves load time, especially on mobile networks. Minification works alongside compression such as gzip or Brotli, and the two gains add up. Build tools usually handle it automatically for production builds. Measure the result with a page weight tool before and after, so you know the change was worth it.
Example
Before:
function addTax(price, rate) {
// calculate total
return price * (1 + rate);
}
After:
function addTax(n,t){return n*(1+t)}
Source maps let developer tools map the minified output back to the readable original.
Common mistakes
- Editing minified files by hand instead of the source.
- Skipping source maps, which makes production errors unreadable.
- Thinking minification replaces server compression. Use both.
Related
Get notified when this term updates
Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.
This page is general information written by our editorial team and updated when documentation changes. Servers and providers differ, so test changes safely first. See our editorial policy and disclaimer.