HTML Preparation code:
Tests:

Historical Performance Data aggregated from 42 community runs

Desktop Results:
Chrome 33 runs
hasAttribute single
10.9M/s
getAttribute single
8.9M/s
getAttribute
8.8M/s
hasAttribute
8.6M/s
classList single
7.9M/s
classList
7.9M/s

Fastest: hasAttribute single (1.4x faster)

View exact numbers
  • hasAttribute single: 10,868,505 ops/sec
  • getAttribute single: 8,891,682 ops/sec
  • getAttribute: 8,766,456 ops/sec
  • hasAttribute: 8,615,559 ops/sec
  • classList single: 7,914,254 ops/sec
  • classList: 7,901,960 ops/sec
Firefox 9 runs
hasAttribute
6.2M/s
classList single
5.1M/s
hasAttribute single
5.0M/s
getAttribute single
5.0M/s
classList
4.6M/s
getAttribute
3.8M/s

Fastest: hasAttribute (1.6x faster)

View exact numbers
  • hasAttribute: 6,228,246 ops/sec
  • classList single: 5,070,446 ops/sec
  • hasAttribute single: 5,016,304 ops/sec
  • getAttribute single: 4,964,732 ops/sec
  • classList: 4,611,404 ops/sec
  • getAttribute: 3,814,051 ops/sec

Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.

Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results
  • Test case name Result
    hasAttribute
    getAttribute
    classList
    hasAttribute single
    getAttribute single
    classList single

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 4 months ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36 Edg/146.0.0.0
Chrome 146 on Windows
View result in a separate tab
hasAttribute single
33.2M/s
hasAttribute
19.8M/s
getAttribute single
19.1M/s
getAttribute
18.4M/s
classList single
17.9M/s
classList
17.5M/s
View exact numbers
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