HTML minification

For general web development questions that are not specifically related to CSS HTML Validator. This includes (but is not limited to) general HTML, CSS, Accessibility, JavaScript, and SEO questions.
BlackWhiteRed
Rank 0 - Newcomer
Posts: 1
Joined: Fri Jan 21, 2011 6:11 am
Location: Arizona

HTML minification

Post by BlackWhiteRed »

Ive been looking into my making my website faster and was wondering if I should minify my html. Is this worth it? I guess what I really need to ask is how much speed improvement I can expect to gain from it. Some of my pages are pretty long with text and illustrations, but all in all pretty normal. What do I need to pay attention to in order not to mess things up? Thanks.
User avatar
MikeGale
Rank VI - Professional
Posts: 726
Joined: Mon Dec 13, 2004 1:50 pm
Location: Tannhauser Gate

Re: HTML minification

Post by MikeGale »

I don't think I've ever gone the minify route with X/HTML.

It's ugly, harder to maintain and of limited benefit.

I don't know any details of your web site. I find a good fast server, compiling the programmed bits and good attention to code design can give lightning speed.

If it's just markup a good fast server still applies. (I've had ISP's move web sites to alternate shared machines to achieve this.)

Working on images is always a good idea and can make a difference. (Note: it's not always the same format that gives you best results, gif, png and jpeg all have their place in the sun.) I'd put that ahead of minification.

I know that some smart people set things up to compress the payload from the server. (gzip) There used to be some problems doing that but I believe it's now much better. I imagine that will also outperform minification.

For a discussion of this issue I found http://stackoverflow.com/questions/7282 ... nification which gives additional hints, including tools that advise you on what to do.

Another thought. If your site has a lot of JavaScript writing it, be very careful. I've recently seen several high profile sites that do this and simply get it wrong. Their code takes so long to run that you just leave the site before it's done.
User avatar
Albert Wiersch
Site Admin
Posts: 3785
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX

Re: HTML minification

Post by Albert Wiersch »

It's hard to help without a link to the site.

Just "compressing" the HTML to remove unnecessary space characters is probably a bad idea and won't help much... but there could other issues that could make a big difference, like large resolutions images that are 500K or larger that are set to display at 200x300 pixels or similar small size. They could easily be downsized and made much smaller in file-size. I've definitely seen that before.

Excessively long pages could also be divided into multiple pages.

Making sure there are no big structural issues in the HTML could also help increase rendering speed (check with a validator like CSE HTML Validator).

And of course what Mike said, a fast server is always good.
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial