Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36
Chrome 89
Windows 7
Desktop
3 years ago
Test name Executions per second
getElementById 2308108.0 Ops/sec
jQuery (tag.id) 237758.6 Ops/sec
jQuery (tag#id) 229293.5 Ops/sec
jQuery (.id) 353996.5 Ops/sec
jQuery (#id) 1054666.2 Ops/sec
Cash + getElementsByClassName 398919.8 Ops/sec
Cash + getElementById 826480.4 Ops/sec
Cash (tag.id) 396284.8 Ops/sec
jQuery + getElementById 957000.2 Ops/sec
Cash (tag#id) 357911.2 Ops/sec
Cash (#id) 1232778.2 Ops/sec
querySelectorAll (.id) 1043636.8 Ops/sec
querySelectorAll (#id) 796107.6 Ops/sec
querySelector (.id) 1896461.0 Ops/sec
querySelector (#id) 1339625.4 Ops/sec
getElementsByTagName 1905994.8 Ops/sec
getElementsByClassName 891989.2 Ops/sec
Cash (.id) 431935.9 Ops/sec
jQuery + getElementsByClassName 254285.2 Ops/sec
HTML Preparation code:
Tests:
  • getElementById

  • getElementsByClassName

  • getElementsByTagName

  • querySelector (#id)

  • querySelector (.id)

  • querySelectorAll (#id)

  • querySelectorAll (.id)

  • Cash (#id)

  • Cash (.id)

  • Cash (tag#id)

  • Cash (tag.id)

  • Cash + getElementById

  • Cash + getElementsByClassName

  • jQuery (#id)

  • jQuery (.id)

  • jQuery (tag#id)

  • jQuery (tag.id)

  • jQuery + getElementById

  • jQuery + getElementsByClassName