Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Feature Request: Minimize html #297

spenserwolz opened this Issue Dec 29, 2016 · 1 comment


None yet
2 participants

spenserwolz commented Dec 29, 2016 edited

I know this is doable by adding grunt or something similar but I'd love if it was built in natively. It could just compile down inside the /build folder, so that leaves the original easily editable.

Minifying HTML is a complex and tricky process, and the value of the minification is often dubious:

Don't Bother Using HTML White-Space Removal

The benefits of minification can be easily overshadowed by the benefits of good coding practices, and using server compression, as explained in this StackOverflow answer by "Mr. Shiny and New":

You have to be careful when removing stuff from HTML as it's a fragile language. Depending on how your pages are coded some of that whitespace might be more significant; also if you have CSS styles such as white-space: pre then you may need to keep the whitespace. Plus there are numerous browser bugs, etc, and basically every character in an HTML file might be there to satisfy some requirement or appease some browser.

In my opinion your best bet is to design the pages well with CSS techniques (I was recently able to take an important page on the site I work for and reduce it's size by 50% just by recoding it using CSS instead of tables and nested style="..." attributes). Then, use GZip to reduce the size of your pages for browsers that understand gzip. This will save bandwidth while preserving the structure of the html.

There is a feature request - issue #346 - for the integration of HTML Tidy into CodeKit, but the purpose there is to use it for linting of the code, rather than minification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment