White space is not “stealing our bandwidth”
Posted January 18th, 2006 in Development, WebI just read yet another article about how extra white space in HTML code is wasting bandwidth. I have several issues with these articles, the first of which is that people actually believe them.
Here are what I think are the main issues:
- Most large sites use HTTP Compression. This means that for all text files (HTML, CSS, JavaScript, etc.) the server is compressing the file before sending it “down the wire”, where your browser will decompress it. GZip is a respectable compressor and will remove almost all redundancies in these files.
- Even if there wasn’t any compression, that whitespace is useful for debugging and then for updates/upgrades, etc. You wouldn’t write all your C/C++/Java code with no extra spaces/newlines because the compile time would be a few milliseconds faster, would you? No, because it would get too difficult to update the file properly.
- The articles always ignore the benefits of your browser cache. Sure Google’s logo image could be more compressed by making it a PNG, but chances are that people who use Google (is there anybody online who doesn’t?) use it multiple times a day, the cache means you likely only download that image once. There are also issues with PNGs and some browsers, for instance older versions of Opera and pre-Tiger Safari will attempt to adjust the colour of PNG files if there is no colourspace info embedded (which would enlarge the file as well). Someone like Google wouldn’t want the colours of their logo changed on certain browsers.
- The argument for using CSS shorthands is somewhat debatable, so feel free to ignore this point. They will make the file smaller (before and after compression), and don’t signifigantly decrease readability. I don’t generally use them because I tend to be more explicit when writing CSS rules. The other reason is that I don’t trust them–getting the same set of CSS rules to work across all browsers is tricky enough without using shorthands.
