HTML minification

Based on https://news.ycombinator.com/item?id=8098317 (HTML minifier revisited) and specifically:

Google minifies HTML on basically all its properties. It’s probably about a 50% savings in bytes, which translates to (on my Comcast connection) about 250ms in network latency saved. Multiply out by rough estimates on queries/day and it saves a human lifetime every 2 days. Repeated experiments - by Google, Amazon, and many smaller websites - have shown that lower latency directly translates to higher conversion rates, so I wouldn’t be surprised if this results in billions of dollars of extra commerce, and even a small website would get noticeably higher revenue if they did this. Google also ranks faster websites higher, and so you get an SEO benefit as well.

Is there a way to make Rails render partials on the same line in the DOM?

I’d like to combine this with a Rake task that copies views to a temp folder, minifies them, and serves them instead of the real views. That way I don’t have to minify HTML with regexes (or at least there’d be less HTML to minify) on each page load.

Thinking this would do well together with gzip compression.

What do you guys think?

Thanks,

Frank

I think what you need is a middleware which compresses the body, like this one: GitHub - paolochiodi/htmlcompressor: A work in progress port of google's htmlcompressor.jar

Nice find!

I made a similar one a while back too:

https://gist.github.com/frankie-loves-jesus/d7eec0ebab0525e94256

Feedback would be much appreciated.

Frank