Wolf’s Little Store

June 4, 2008

Wherein I discuss stylesheets (1)

Even though almost everyone has broadband by now, it’s still a good idea to minimize filesizes. The difference between a 15kb and 10kb CSS file is barely noticeable on a high end PC with a broadband connection; however, things change when accessing content from mobile devices. Or when extreme multitasking. Or when surfing from a low-end PC (like the Asus EEE PC).

That doesn’t mean you need to strip out of all of your comments and blank lines - if you really want the ultimate performance, there’s caching and minifiers out there. But for most projects we don’t use these, and then it’s a matter of optimizing the most with the least amount of extra effort.

Scouting in old stylesheets I found some questionable CSS. Sometimes we develop these habits which make no sense at all when you think of them. An example:

background: transparent url(bg.gif) no-repeat top left;

Since transparent is the default background color, and top left is the default positioning, there’s no point in repeating yourself. It’s better to write it like this:

body { background: url(bg.gif) no-repeat; }

DRY like yo momma.

Leave a Reply

Write in English, stay on-topic and polite.