3 ms·
None of your first three points are really a problem. No, you won't be able to do a simple regex based solution, but the rules for where whitespace matters in H
by mistercow 14y ago
None of your first three points are really a problem. No, you won't be able to do a simple regex based solution, but the rules for where whitespace matters in HTML are rigorously standardized. Obey them, and your minifier will work just fine.
>1) GZIP if used will make the impact of scrubbing out whitespace almost nonexistent
Maybe if you were just removing whitespace (although you still will see a difference). Removing comments and omitting optional closing tags will take you further. Minified JS compresses smaller than un-minified JS, so it's reasonable to think the same would be true of HTML.
>Most HTML served is dynamic, meaning that the HTML compression will need to be run on every HTML response - this could have some performance negatives. (If your just compressing static HTML once it should be fine.)
For templated HTML, the minification should be done on the template itself, not on the final output. You really do have to weigh the pros and cons of GZIPping dynamically generated HTML, so pre-minified HTML templates could be a pretty big win.