GUIDE深度 · Deep dive
What HTML Minification Does
HTML minification removes comments, collapses whitespace and may drop optional tags. It is riskier than CSS/JS minification because whitespace between inline elements can affect layout.
Common optimizations
Remove comments and indentation.
Collapse whitespace between tags.
Drop optional closing tags (carefully).
Risks
Whitespace between inline-block elements affects spacing.
Never minify inside pre, textarea, script or style.
FAQ
Is it redundant with gzip?
It helps but gains shrink; removing unused content matters more.
Do I need a build tool?
Use mature tools like html-minifier-terser in production.