Website code optimisation?

Associate
Joined
10 Jul 2006
Posts
2,423
Given its the advances in internet speed, do people still optimise their html/css/javascript to take up a minimal amount of space so that it loads faster? Like removing whitespace, tabs, keeping variable names short...

Eg this:

Code:
#id{color:#fff}

instead of:

Code:
#id
{
   color: #fff;
}
 
For CSS I tend to prefer the second approach because it's easier to read. For JavaScript I'll minify libraries (i.e. jQuery plugins) but unless my own code is massive I'll leave it uncompressed for ease.

Besides, unless you've got massive JS/CSS files I doubt it would make a difference, especially if your server is gziping them before being sent to visitors and their browser is caching the files anyway.
 
The difference it will make to the size of your css, javascript is so minimal on most sites compared to the savings that can be made elsewhere, that you will probably find that you just cause yourself more problems than its worth.
 
The reason Google have it all on one line is not to minify, it'll be because they don't write the markup directly and use a dom generator like everyone should :p
 
Whitespace makes next to no difference to a text files size (literally just a few bytes), so it's always best to write in in the most readable way.
 
I actually write my CSS condensed because I find it easier to work with as I can see a lot more rules on the screen at any one time.

CSS has never been large if used properly. It's only an issue if you have divitis.
 
For CSS I tend to prefer the second approach because it's easier to read. For JavaScript I'll minify libraries (i.e. jQuery plugins) but unless my own code is massive I'll leave it uncompressed for ease.

Quoted For Ye Truth

In your example OP there's six bytes difference, but your example's very small. In the real world, there'll be many more characters per line, so the proportion that're newlines/tabs will be minimal.

Plus, I edit live, so if I minified before pushing live I'd not be able to do that.
 
Back
Top Bottom