Live data from Hacker News

Don't use class names to find HTML elements with JS

roytomeij.com

1–7 of 7 posts

Re: Don't use class names to find HTML elements with JS

#2
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.

Re: Don't use class names to find HTML elements with JS

#5
post #4

I guess this will be terribly slow in Internet Explorer.

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.