News for hackers. Stuff that matters.
Re:Ask HN: Why do we minify JavaScript, yet not HTML? by pestaa on Sunday December 02, 2012 @04:21PM (#4862561)
I love optimizing front-end including HTML outputs, even prematurely so. My sites are low-traffic and lightweight anyway, but for me this is a form of zen.
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.)
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);
Re:Ask HN: Why do we minify JavaScript, yet not HTML? by cheald on Sunday December 02, 2012 @06:41PM (#4863126)
Hope you don't have any <textarea> or <pre> tags on the page.
Re:Ask HN: Why do we minify JavaScript, yet not HTML? by maratd on Sunday December 02, 2012 @10:16PM (#4863733)
I don't, but unless you fill them full of whitespace and nothing else, they won't match.
Re:Ask HN: Why do we minify JavaScript, yet not HTML? by TazeTSchnitzel on Sunday December 02, 2012 @04:23PM (#4862571)
Your website's HTML isn't minified ;)
Re:Ask HN: Why do we minify JavaScript, yet not HTML? by pestaa on Monday December 03, 2012 @03:27AM (#4864495)
It is not an active one as you can probably tell...