Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36
Chrome 116
Mac OS X 10.15.7
Desktop
one year ago
Test name Executions per second
data attribute 410671.7 Ops/sec
class name 598574.9 Ops/sec
class name with data attribute 385780.0 Ops/sec
HTML Preparation code:
AخA
 
1
<div class="test" data-attribute="test"></div>
2
<div class="test" data-attribute="test"></div>
3
<div class="test" data-attribute="test"></div>
4
<div class="test" data-attribute="test"></div>
5
<div class="test" data-attribute="test"></div>
6
<div class="test" data-attribute="test"></div>
7
<div class="test" data-attribute="test"></div>
8
<div class="test" data-attribute="test"></div>
9
<div class="test" data-attribute="test"></div>
10
<div class="test" data-attribute="test"></div>
11
<div class="test" data-attribute="test"></div>
12
<div class="test" data-attribute="test"></div>
13
<div class="test" data-attribute="test"></div>
14
<div class="test" data-attribute="test"></div>
15
<div class="test" data-attribute="test"></div>
16
<div class="test" data-attribute="test"></div>
17
<div class="test" data-attribute="test"></div>
18
<div class="test" data-attribute="test"></div>
19
<div class="test" data-attribute="test"></div>
20
<div class="test" data-attribute="test"></div>
21
<div class="test" data-attribute="test"></div>
22
<div class="test" data-attribute="test"></div>
23
<div class="test" data-attribute="test"></div>
24
<div class="test" data-attribute="test"></div>
Tests:
  • data attribute

     
    var test = document.querySelectorAll('[data-attribute="test"]');
  • class name

     
    var test = document.querySelectorAll('.test');
  • class name with data attribute

     
    var test = document.querySelectorAll('.test[data-attribute="test"]');