Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36
Chrome 77
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 2288377.8 Ops/sec
getElementsByClassName() 1559041.9 Ops/sec
getElementsByTagName() 1894225.5 Ops/sec
querySelector(#id) 1553342.1 Ops/sec
querySelector(.id) 2041948.1 Ops/sec
querySelectorAll(#id) 833124.0 Ops/sec
querySelectorAll(.id) 1037601.4 Ops/sec
jQuery(#id) 907596.1 Ops/sec
jQuery(.id) 403482.7 Ops/sec
jQuery(tag#id) 296311.1 Ops/sec
jQuery(tag.id) 304770.7 Ops/sec
jQuery + getElementById 1032511.5 Ops/sec
jQuery + getElementsByClassName 370169.8 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