--
You received this message because you are subscribed to the Google Groups "Object Oriented CSS" group.
To post to this group, send email to object-or...@googlegroups.com.
To unsubscribe from this group, send email to object-oriented...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/object-oriented-css?hl=en.
With a good testing environment, http://benchmarkjs.com/ or some benchmarking with console.log( new Date().getTime() ) can make it possible for you to decide what is best.
I have worked with sites with HTML documents counting 10k+ elements, on those it was really important to choose the correct hooks. Typically, though, 10k+ elements are extreme and "normal" sites are not really in any need of premature optimization.
If you want to read about it, consider Souders saying about it, for example:
http://www.stevesouders.com/blog/2009/03/10/performance-impact-of-css-selectors/
Personally I prefer IDs for unique stuffs. Best of all, though, is to skip JavaScript as long as possible. :)
/ay
--
You received this message because you are subscribed to the Google Groups "Object Oriented CSS" group.
To view this discussion on the web visit https://groups.google.com/d/msg/object-oriented-css/-/YiR4_26JIuUJ.
I hadn't considered hanging unit tests off separate classes but it makes sense - I'll try to adopt that in future. I know what you mean about
<div class="review js-review qa-review">
not "feeling" right. I used to feel the same way but these days I can't think of a single good reason not to do this (other than some sort of vague guilt about "classitis"). I can't speak for other devs but I grew up learning that classes and IDs should be named based on the content - we were told that class and ID names were an opportunity to endow your content with the magical pixie dust of semantics. But semantics is all about the relationship between symbols and meaning. And meaning depends on our audience - who is reading the code and what are they trying to get out of it. To my mind, our class and ID names are symbols that communicate to two audiences (ignoring microformats as a special case) 1. Our other code (the robots) 2. Other developers
Nobody else reads or cares about our class and ID names. For some reason it took me an inordinately long time to accept that last statement (not the sharpest tool in the box sometimes). Even now it still "feels" wrong but I haven't found any compelling evidence against it. And y'know what, our robots (other code) don't care about what names we use either! - the browser would be just as happy with
<div id="iuj" class="xgt fjl">
as long as our CSS and JS use the same symbols. So our only audience for class and ID names are other developers and the meaning they want to extract from our code is knowledge of how it is structured and how to safely make changes.
We could create a completely unique vocabulary for each site (rough analogy with an XML approach) but some sort of shared set of symbols that have an agreed upon meaning (the HTML approach) really speeds up communication. A sensible set of prefixes and clear separation of concerns goes a long way towards this I think. To my mind, this is one of the big wins of the OOCSS approach. Looking at
<div class="review js-review qa-review">
again, I can guess that this block is touched by JS and has at least one unit test associated with it and that the dev team that created it have labeled it a "review". Compare this with
<div class="review">
where I only learn that, in the vocabularly of the devs that created this page, this block is described as a "review" which doesn't tell me much, especially as in the real world it's likely to appear as
<div class="review">
<h1>Review</h1>
...
</div>
I have heard folks argue that this approach bloats the markup - certainly the markup gets bigger but (in my experience at least) my CSS is much smaller and I would question how much of a real world performance problem of slightly bigger markup is provided it is served using gzip compression.
Thanks for your time.
/Eoin/
--
You received this message because you are subscribed to the Google Groups "Object Oriented CSS" group.
To view this discussion on the web visit https://groups.google.com/d/msg/object-oriented-css/-/jz9sbg6uX54J.