Pentagramme

Minify Your HTML

by Keefe Tang

Yesterday I re-posted an article series originally published on my old website. I will continue to post a few others where the topics that were discussed are still relevant.

The reason I choose website optimisation first it is more relevant than ever. Though there are a few new website optimisations I could include, I think HTML minification is a more interesting topic for me given it’s lack of exposure.

HTML minification have not been discussed much when it comes to website optimization and there is very little useful tools that can do the job correctly. Unlike scripts and stylesheets, minifying HTML does not produce better compression. Couple that with the rise of blogging platform means webpages are more dynamic than scripts and stylesheets.

It’s no suprise then that HTML minification is always a low priority website optimisation, sometimes not even included in the list of things to optimise. However I still believe there is value to minify your HTML documents, especially when you host a site from static HTML files like myself.

One useful HTML minification tool I found is Smaller which offers HTML, PHP, CSS and JavaScript minification. The actual HTML and PHP compression is handled by htmlcompressor while CSS and JavaScript compression is handled by YUI Compressor and Smaller acts as a wrapper for both tool with the convenience of a GUI application.

For someone like me that generate and upload Pentagrammme by executing a simple script, using Smaller will mean I need to generate my site, drag and drop the folder with the generated files then upload the site and that does not translate into the most intuitive workflow. Nevertheless Smaller is a very convenient application, just by draging and droping the folder containing all the files to be minified is all it takes to minify the files; and yes, it recursively checks for all file format it supports.

What is lacking in terms of HTML minification is warnings about inline styles, scripts and deprecated HTML elements & attributes and removal of empty elements like <p></p> that can save you much more space than a simple minification can do.