Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36
Chrome 79
Linux
Desktop
4 years ago
Test name Executions per second
getElementById() 3382965.0 Ops/sec
getElementsByClassName() 2165037.2 Ops/sec
getElementsByTagName() 2734614.2 Ops/sec
querySelector(#id) 2036562.0 Ops/sec
querySelector(.id) 2749993.8 Ops/sec
querySelectorAll(#id) 964991.8 Ops/sec
querySelectorAll(.id) 1186121.1 Ops/sec
jQuery(#id) 986204.4 Ops/sec
jQuery(.id) 502451.7 Ops/sec
jQuery(tag#id) 329613.1 Ops/sec
jQuery(tag.id) 352716.0 Ops/sec
jQuery + getElementById 1288985.8 Ops/sec
jQuery + getElementsByClassName 459200.6 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