Don't go crazy with this idea
Monday July 17, 2006
But getting rid of white space in your HTML can help you with the download times of your pages. Now, don't get me wrong, I am not a proponent of getting rid of all white space in HTML. I like to be able to read pages that I have to edit later - and having them be all one line might make them load faster, but spending an extra 30 minutes to edit it doesn't improve the page enough. That said, getting rid of white space in your HTML can help improve your download times.


Comments
We are talking about a byte per character here. Even if you got 1000 (or let’s say 1024) of those, it’s just a kilobyte of saved bandwidth. On a 56k analog telephone line that’s 0.14 seconds. Is that worth the troubles?
Though using the right indents is very important indeed, no doubt about it.
1. If you’ve ever seen what a database driven site can do to the spacing, you would realize that it is worth the trouble - some pages I’ve seen can add hundreds and hundreds of extra whitespace characters that can make a huge difference in the size of the code.
2. I’m not suggesting that people go wild with this - some sites have taken this idea to the extreme and deleted every extraneous space, quote-mark, and attribute. Their code is lean, but it’s often not standards compliant and very hard to edit later.
3. “Just a kilobyte” gives you another KB for an image that might not have had that space. Most of the designers I’ve met would rather spend bandwidth on images that people see than on whitespace that they don’t.
4. While 1KB might not seem like a lot, if you have a large site that becomes magnified. For example, if you have bandwidth restrictions and a site with 1000 pages, saving 1KB per page would result in a megabyte of bandwidth savings. And the more pages you have, the more you save.
As I say in the blog post, I’m not advocating going crazy, but being aware of when you’re using whitespace that you don’t really need to can save you bandwidth in the long run.
I see your point, but I still don’t completely agree. A one kilobyte save is only possible with deleting 1024 whitespace characters. I guess that’s not the case for most pages. Except for when you delete all the indenting which is not an option (as we both agreed on).
Of course having a big website makes more difference, but the relative difference is still small. You still just save only 0.001% (or whatever) of bandwidth. If your site uses gigabytes of bandwidth then yes, it may save you 100 MB per month. 100 MB is just nothing compared to those gigabytes. Compare the time used for ‘optimizing’ the website to the extra bandwidth costs and I don’t think it’s worth it.