hasAttribute vs getAttribute vs classList vs hasAttribute single vs getAttribute single vs classList singleFastest: hasAttribute single (1.4x faster)
10,868,505 ops/sec
8,891,682 ops/sec
8,766,456 ops/sec
8,615,559 ops/sec
7,914,254 ops/sec
7,901,960 ops/sec
Fastest: hasAttribute (1.6x faster)
6,228,246 ops/sec
5,070,446 ops/sec
5,016,304 ops/sec
4,964,732 ops/sec
4,611,404 ops/sec
3,814,051 ops/sec
Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.
| Test case name | Result |
|---|---|
| hasAttribute | |
| getAttribute | |
| classList | |
| hasAttribute single | |
| getAttribute single | |
| classList single |
| Test name | Executions per second |
|---|---|
| ✓ hasAttribute single | 33,201,924 Ops/sec |
| hasAttribute | 19,811,070 Ops/sec |
| getAttribute single | 19,131,410 Ops/sec |
| getAttribute | 18,429,714 Ops/sec |
| classList single | 17,932,164 Ops/sec |
| classList | 17,511,880 Ops/sec |