Optimize Your Code

A lot of people don’t realize that the white space in your code takes up bandwidth. Each hit on the return key, and each tap on the space bar is information that needs to be down loaded to the browser.

One of the online html optimizers suggested that 20% of your bandwidth is saved. The last css sheet I optimized saved 37%. That one was quite large, for a forum, and had a lot of comments.
Css first. To do it, just find your .css style sheet. A link to it will be toward the bottom of your head section on the html page. Copy the whole thing and save a copy. This isn’t just for back up. Most css optimizers strip out the comments.

If you do want to modify the css in the future you can work from the back up sheet. That’s if you have comments. If you don’t the css optimizers will reverse the process. Just paste the single line of code in and select high readibility.

You can choose degrees of optimization with the css optimizers. For heavy traffic (yes!!) you can reduce the code to a single horizontal line. I have been doing this for a year without a problem. In fact I usually learn something when I do it. A css short hand that I missed, or 2 different declarations that were identical.

I don’t want to recommend one. You can find plenty at Google.

This doesn’t just save bandwidth, but also disk space and stress on the server. With Google taking page load time into account now, it might even help your ranking.

For html it is just a bit more tricky. I just tried it on a site lately and out of a dozen pages 2 were messed up. An Amazon affiliate banner 160 px wide by 600 high, was displayed as 468 wide by 60 high (!) Messy. Wrecked the layout.

The work around was to reduce everything up to the ad to a single line, and then everything after it. Just to be safe I do this with anything that has script and /script tags.

I’ve also had problems with IE 6 not showing a page when the head was in a single line.

Also I haven’t seen an html optimizer that will reverse the process. (I’ve only used 2).

For an interesting example look at the source (Ctrl + U) of the Google search page. Just about a dozen lines, one of them going about 40 scrolls to the right. Also notice that it doesn’t have an /body or /html tag, for the most interesting of reasons.

That’s to save on bandwidth too! I read about that on one of their blogs. None of the browsers do anything with those tags. Guess the validators are just playing catch up.

With the amount of bandwidth they use just with utube, you might not expect this. It’s a nice lesson for me. No point in wasting anything.

Leave a Reply

Your email address will not be published. Required fields are marked *