Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
DataAttribute vs Class Selector vs ID Selector (extended)
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Browser:
Chrome 120
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
Benchmark engine:
Benchmark.js
class
6.5M/s
ID
4.7M/s
data-attribute
4.1M/s
data-attribute exact
2.1M/s
data-attribute partial
2.0M/s
View exact numbers
Test name
Executions per second
✓
class
6,505,100 Ops/sec
ID
4,700,824 Ops/sec
data-attribute
4,127,105 Ops/sec
data-attribute exact
2,051,577 Ops/sec
data-attribute partial
2,014,255 Ops/sec
HTML Preparation code:
<div class="hello" id="hello" data-hello data-test="hello-and-bye">Hello</div>
Tests:
class
document.querySelector('.hello');
ID
document.querySelector('#hello');
data-attribute
document.querySelector('[data-hello]');
data-attribute partial
document.querySelectorAll('[data-test~="hello"')
data-attribute exact
document.querySelectorAll('[data-test="hello-and-bye"]')