|
|
|
|
|
by rimantas
5799 days ago
|
|
My take on this: the game is not worth the candle. Usually there are lower hanging fruits to be gathered regarding client-side performance, and I am not even sure it is worth to bother with CSS performance: 100ms on huge page is not that much. Also there are other factors to consider: adding classes to your markup will increase it's size, and it will be downloaded every time (with millions of hits it adds up). CSS on the other hand can be cached and have zero impact on load time (expires set into future). Non-semantic class names are ugly.
My ideal page would use as little IDs and classes as possible (preferably none, doable with HTML5 where you can use semantic elements instead of trying to give some semantic meaning to the DIV via some class name). Yes descendent selectors and friends are slower than direct targeting with id or class, but the difference is negligible.
Spend your time reducing the number of http requests, minimizing js, taking care of parallel loading, setting proper expires and cache control headers, don't sweat about CSS selectors speed. |
|
re: zero-impact if cached: I assume you mean visitors that have already downloaded your css from a previous visit? That's been shown to be inaccurate. I also would assume that you have css with far future expires and is zipped, (possibly URI'zed), and on a fast CDN. (not all CDN's are fast). Yet there is no such thing as zero impact. The css still has to be painted on the page and even when cached. If your CSS is 500kb, that could take a long time for a browser to parse CSS.
re: non-semantic class names.. it's a test.. nuf said
re: your ideal site: There't lots I could say here.. besides the fact that IE is still to simpleton to understand most selectors I assume you are speaking of. Also, if you are talking about decendent selectors like I am thinking.. check the Link to Steve Souder's site.. they talk on that. (hint: they're faster)
again, this is assuming you have done all of the other things.. and then some. There is much more you can do before optimizing your css.. but some are at that point. Just because it doesn't apply to you, doesn't mean it isn't an issue to others.. Nor does it mean we should assume there is no issue, without testing and measuring (in order to make sure.)