

Don't use class names to find HTML elements with JS - roytomeij
http://roytomeij.com/2012/dont-use-class-names-to-find-HTML-elements-with-JS.html

======
unfletch
The title of this article should have been "Don't use class names to store
data." Finding elements by class name is fine. This is about misusing the
class attribute.

~~~
roytomeij
Good one, thanks!

------
kls
I am actually working on some CMS templating for a flat HTML templating engine
and making heavy use of the data attribute for it. I think it is one of the
greatest additions to the HTML standard. I like that I did not have to use a
cutom built templateing variable / languadge to indicate that a template
should go into a node. It is my hope that a CMS standard will evolve out of
data attributes so that we can get rid of the 1000's of different variations
of a simple thing like put the content here.

------
voidr
The title is wrong, it basically says: don't store your data in class names
and separate your styling from your code logic.

------
arvidj
I guess this will be terribly slow in Internet Explorer.

~~~
roytomeij
It is, with IE9 handling just over 7,000 operations per second (based on the
jsPerf test: <http://jsperf.com/long-selectors-vs-data/2>) vs. 25,000 in
Chrome. Don't go all out I'd say, but in most scenario's even that number of
operations will be acceptable.

