Glossary / Minification

Minification

Minification transforms source code to reduce emitted size, usually by removing whitespace and comments, shortening identifiers, and simplifying expressions. It can reduce network transfer, but it is distinct from compression (gzip/Brotli), transpilation, and tree shaking; it can also make debugging and error reporting harder if source maps are missing or incorrect.

Transformations and constraints

A minifier parses code and applies semantics-preserving transformations under assumptions about the language target and runtime. Property mangling is often opt-in because changing property names can break reflection, JSON protocols, CSS selectors, or external consumers. Aggressive compression can expose bugs in code that relies on undeclared globals or side-effect assumptions. License comments and legal notices may need preservation by policy.

Minification is usually most valuable for production assets alongside Brotli/gzip. Measure transfer size and parse/evaluate cost; smaller bytes do not always mean faster execution. Minifier settings may affect output shape and stack traces, so pin tool versions and test production builds.

Source maps and privacy

Source maps map generated positions back to authored files. They can be uploaded privately to error-monitoring services without public deployment, or served with the bundle depending on policy. Maps may reveal source code, paths, or embedded source content; inspect sourcesContent and access controls. Keep maps tied to exact deployed artifact hashes.

Interview questions

  1. Minification vs compression? Minification rewrites source; compression encodes transfer bytes at the transport/server layer.
  2. Can property mangling be risky? Yes, external property access, reflection, or serialized contracts may break.
  3. Does smaller code always execute faster? No; parse, runtime behavior, caching, and algorithm cost also matter.
  4. Why retain source maps? To map production errors to authored source.
  5. What should be measured? Compressed transfer size, parse/evaluate cost, runtime behavior, and error quality.

References