Export to GitHub

page-speed - MinifyHtml.wiki


Minify HTML

This rule is currently still experimental, as there are a number of difficulties with minifying HTML:

  • Comments can generally be removed from HTML, but some tools may rely on certain special comments being present in the HTML. Page Speed's HTML compactor recognizes and preserves certain classes of important comments, but may unwittingly remove others that should not be removed. If you encounter such a case, please file a bug.
  • Whitespace between tags can generally be collapsed, except within whitespace-significant blocks. Page Speed's HTML compactor will avoid collapsing whitespace within, for example, <pre> tags, but currently it may still incorrectly remove whitespace from other blocks that use CSS rules to make whitespace significant.
  • Many HTML pages are generated dynamically, in which case the minified HTML file produced by Page Speed cannot simply be used as a drop-in replacement. However, you may, for example, want to use fragments of the minified HTML within a template used to generate the page.