Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36
Chrome 78
Mac OS X 10.15.1
Desktop
5 years ago
Test name Executions per second
getElementById() 3887813.2 Ops/sec
getElementsByClassName() 2338465.5 Ops/sec
getElementsByTagName() 3525393.5 Ops/sec
querySelector(#id) 2472002.0 Ops/sec
querySelector(.id) 3576674.8 Ops/sec
querySelectorAll(#id) 1163901.6 Ops/sec
querySelectorAll(.id) 1638055.1 Ops/sec
jQuery(#id) 1424856.9 Ops/sec
jQuery(.id) 666854.7 Ops/sec
jQuery(tag#id) 446832.5 Ops/sec
jQuery(tag.id) 466869.7 Ops/sec
jQuery + getElementById 1803815.5 Ops/sec
jQuery + getElementsByClassName 569444.1 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