How is CSS faster than ...

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

How is CSS faster than ...

Post by nigma »

How is the use of CSS ( body { background-color: red; } ) faster than specifying the attribute in the HTML code ( <body bgcolor="red"> )?

Thanks for any help provided.
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

Just a clue: maybe because the CSS file is saved to the browser's cache and then it does not need to be reloaded. Considering you are using a CSS file, something like:

Code: Select all

<link rel="stylesheet" type="text/css" href="sc_style.css" />
and other pages of your application make use of it.

Regards,
Scorphus.
User avatar
brewmiser
Forum Commoner
Posts: 74
Joined: Mon Aug 18, 2003 12:50 pm
Location: Dallas, TEXAS

Post by brewmiser »

The only way that I know that a CSS is faster is when it comes to design issues. It makes it easier to change multiple pages in one file then in all of them.

In case you do not like your webpage with a background color of red you can go to the CSS and change the color to blue.....and....wam bam .... it's done through out the entire site!
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

Alright, thanks a lot, I didn't know the CSS file was stored in Cache.
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

Simply put a properly designed XHTML and CSS site weigh's much less than a traditional table-based site design. Because the CSS is the same on the pages, it's cached (just like an image would be).

So the only thing a browser downloads is the XHTML, which, if done correctly, is very, very light.
Unipus
Forum Contributor
Posts: 409
Joined: Tue Aug 26, 2003 2:06 pm
Location: Los Angeles, CA

Post by Unipus »

Correct. It's faster only when they are multiple redundant instances of the same stylings. But, if you're designing and writing your CSS correctly, there should be.
Post Reply