Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.




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

Search: