Re: comments on Selectors

Boris Zbarsky wrote:

>>Its been a while since I read it and who knows how up-to-date the 
>>document is.
>>    
>>
>
>It's up to date.  All it says is that a rule like:
>
>*:empty { color: red }
>
>will take longer to process than a rule like
>
>.empty-stuff { color: red }
>
>because the former will be compared to all elements.
>

Again, note the difference in the selectors.

*:empty
is functionally (and performance) equivalent to
:empty

.empty-stuff
is functionally (and performance) equivalent to
*.empty-stuff

There is no performance difference (in Mozilla) for having an implied or 
explicit * portion of a selector.

>
>The perf difference is hard (if possible) to notice on a typical web page; that
>document's primary audience are people writing Mozilla themes and XBL (the
>amount of CSS in a typical Mozilla theme plus the default CSS that's always
>applied to the chrome is easily 10 times larger than the amount of CSS I've
>seen in any web page...)
>
Agreed, also note that the performance hit really comes from having a 
large number of rules where the final selector has no type, class or ID 
component (because each of those rules is then be tested against every 
node in the DOM tree).

Received on Tuesday, 18 February 2003 01:01:19 UTC