Dispelling a Myth
I’ve been seeing this quite a bit lately, and its really quite annoying. You’ll usually see it in ‘Be a Master’ type posts on various blogs. And its unfortunate that it is being circulated.
So what exactlly is this problem? I call it the File Size Myth, and it goes something like this: “Don’t comment your code and try to keep things on one line to reduce your file size……….” I even read one post where the author suggested putting comments in a seperate file.
Now one the surface this seems pretty reasonable, and it does reduce the file size and decrease download times, however………. the amount of space saved, and the amount of time saved is miniscule. So small in fact that its really a waste of time to do these things.
You might be able to save a few bytes of space, and IF you have a really large file, maybe 300 – 400ms on the download. Sounds like a lot, but in reality its not. Considering that many HTML files average 10-20KB (10240 – 20480 bytes) a few bytes is pretty small and 300-400ms is about the duration of the average eye blink, we’re not saving much time or space.
What you are doing is making your code more difficult to maintain. If you revist your code a few months or even a year later, you’re going to be spending a lot of time trying to figure out why you did what you did, a lot of time you could have saved if you had commented your code in place, and not crammed as much as possible onto one line.
This myth comes from the days when dial-up was king and broadband was virtually unheard of. But today with the prevalence of broadband internet connetions, and dial-up hosts caching nearly every page, this is not a problem. So do yourself and others a favor, comment your code, and don’t cram everything on one line.

Add A Comment