Hacker News new | past | comments | ask | show | jobs | submit login

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.



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.)


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);


Hope you don't have any <textarea> or <pre> tags on the page.


I don't, but unless you fill them full of whitespace and nothing else, they won't match.


Your website's HTML isn't minified ;)


It is not an active one as you can probably tell...




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: