i am planning to use data- attributes to identify elements in DOM for selenium test cases. Will the usage of attributes affects application performance?
Asked
Active
Viewed 1,587 times
3
-
compared to not using them and using only css which may change drastically in the future. I want to know whether application slows down if i use lots data-attributes – Amareswar May 21 '12 at 19:01
-
@Amareswar: What do `data-` attributes have to do with CSS? – gen_Eric May 21 '12 at 20:28
-
@Rocket, i am planning to use data- attributes instead of using css classes while finding an element – Amareswar May 22 '12 at 19:53
-
1@Amareswar: Classes would definitely be faster if you're selecting elements. – gen_Eric May 22 '12 at 19:56
-
1A more formal answer http://stackoverflow.com/a/15010727/1559840 – Amir Nissim Jul 25 '13 at 13:59
1 Answers
4
Not at all, you'll be fine with using data-*
attributes. However, you should note that using the syntax $.data(theInput, 'someData');
is much faster than using the syntax theInput.data('someData');
, as demonstrated in this jsPerf.

Elliot Bonneville
- 51,872
- 23
- 96
- 123
-
1The link you posted only compares the various was to get data attributes. However, according to http://jsperf.com/class-vs-data-attribute-selector-performance it seems that get dom elements using data attributes instead of css selectors is about 98% slower! – Angel S. Moreno Sep 30 '14 at 20:45