Re:Ask HN: Why do we minify JavaScript, yet not HTML?
by salehenrahman on Sunday December 02, 2012 @04:24PM
(#4862573)
Just curious: what do you use to minify? In an earlier comment, I said that most templating engines that I used don't minify. You'd have to write your own minifier. (I used Jinja, by the ways.)
[ Parent
| on HN ]
Re:Ask HN: Why do we minify JavaScript, yet not HTML?
by maratd on Sunday December 02, 2012 @04:55PM
(#4862679)
It's pretty simple. Use a regex to eliminate whitespace and then gzip. Be sure to set the proper headers if you gzip.
I eliminate whitespace with the following PHP code:
preg_replace(['/\t+/', '/>\s+</'], [' ', '><'], $html);