Skip to content

Minification

Entry #233 / 700 · Chapter 5 · 5.2 Speed, rendering and modern front-ends · Read in Chinese →
In one sentence

Removing whitespace, comments and redundant syntax from code without changing behaviour.

Analogy Mental model

Condensing a long document into its essentials. Same meaning, far fewer pages.

In practice What you actually do

The build tool does this by default; make sure it is on for production and off for development. Keep source maps published privately so a stack trace from a customer still points at a line of real code.

Where people get burned Pitfalls

Hand-minifying files that are later edited is how a site ends up with two divergent copies of the same script. Let the pipeline own it, and cache-bust with a content hash.

This entry was written in English from the Chinese original, not machine-translated. Read the Chinese version →