This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Stylesheets > February 2006 > Optimizing CSS





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Optimizing CSS
Tony

2006-02-07, 11:40 pm

Hi -

I have a really massive stylesheet, and I want to trim it down to a
more reasonable size. So, what I'm wondering is if anyone can recommend
any decent online tutorials (preferred) or maybe a book about the
subject?

Of course, I can Google for "CSS optimization" and other such queries,
but that doesn't necessarily mean the tutorials are any GOOD :) --
Which is why I'm asking your opinions.

Thanx

Jim Moe

2006-02-07, 11:40 pm

Tony wrote:
>
> I have a really massive stylesheet, and I want to trim it down to a
> more reasonable size. So, what I'm wondering is if anyone can recommend
> any decent online tutorials (preferred) or maybe a book about the
> subject?
>

An URL would help.
In general:
1. The large size is often because every conceivable bit of style used by
a site is crammed into one file. Split out those sections that apply to
only a few pages and import those separately.
2. Use the "C" part of CSS, cascading. A lot of redundancy is because a
style is not cascaded for elements and separate classes are created where
none are actually required.

--
jmm (hyphen) list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
Mark Parnell

2006-02-07, 11:40 pm

> Tony wrote:[color=darkred]

I have found http://flumpcakes.co.uk/css/optimiser/ to be useful - the
output generally needs a little bit of tweaking, but it's a great start.

--
Mark Parnell

I give up:
http://blinkynet.net/comp/uip5.html
Gérard Talbot

2006-02-07, 11:41 pm

Tony wrote :
> Hi -
>
> I have a really massive stylesheet, and I want to trim it down to a
> more reasonable size. So, what I'm wondering is if anyone can recommend
> any decent online tutorials (preferred) or maybe a book about the
> subject?
>
> Of course, I can Google for "CSS optimization" and other such queries,
> but that doesn't necessarily mean the tutorials are any GOOD :) --
> Which is why I'm asking your opinions.
>
> Thanx
>


Usually, the mistake people do is not understanding how CSS inheritance
works. So, they over-declare, over-define CSS rules. They also create
classes for everything possible, not understanding again how inheritance
works and when a CSS property is and is not inherited.
Also, they seem to ignore most of the CSS default values of elements.

"Classitis and Divitis
A common error of beginning CSS coders is to use far too many <div> tags
and class attributes (...) Ninety-nine out of a hundred times these
complicated structures are unnecessary."
Web Page Development: best practices
http://developer.apple.com/internet...bestwebdev.html

So, reducing DOM tree depth generally also reduces the need of a complex
stylesheet.


Excellent/recommendable resource is:

Style sheet master class: part 1 - writing perfect style sheets
http://www.richinstyle.com/masterclass/perfection.html


Also good (regarding parsing purposes) is:
Writing Efficient CSS
http://developer.mozilla.org/en/doc...g_Efficient_CSS

Gérard
--
remove blah to email me
Gérard Talbot

2006-02-07, 11:41 pm

Tony wrote :

>
> I have a really massive stylesheet, and I want to trim it down to a
> more reasonable size. So, what I'm wondering is if anyone can recommend
> any decent online tutorials (preferred) or maybe a book about the
> subject?



Also:

"Superfluous elements and classes
When starting out with CSS, it's common to make the mistake of using
unnecessary (X)HTML elements, superfluous classes, and extra <div>
elements. This doesn't necessarily mean that the code will be invalid,
but it counteracts one of the reasons of separating structure from
presentation; to get simpler, cleaner markup."
coming from
Developing With Web Standards
Recommendations and best practices
6. CSS
http://www.456bereastreet.com/lab/d...ndards/css/#css

Gérard
--
remove blah to email me
Stan Brown

2006-02-20, 3:29 am

Thu, 02 Feb 2006 07:17:31 -0500 from Gérard Talbot
<newsblahgroup@gtalbot.org>:
> "Classitis and Divitis
> A common error of beginning CSS coders is to use far too many <div> tags
> and class attributes (...) Ninety-nine out of a hundred times these
> complicated structures are unnecessary."
> Web Page Development: best practices
> http://developer.apple.com/internet...bestwebdev.html


I'm not sure I'd put a lot of faith in anything that page says since
it recommends using tables for layout. No way can that be called
"best practices" IMO.

--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2.1 spec: http://www.w3.org/TR/CSS21/
validator: http://jigsaw.w3.org/css-validator/
Why We Won't Help You:
http://diveintomark.org/archives/20...e_wont_help_you
Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews