Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36
Chrome 76
Mac OS X 10.14.6
Desktop
5 years ago
Test name Executions per second
getElementById() 3766509.0 Ops/sec
getElementsByClassName() 2277721.8 Ops/sec
getElementsByTagName() 2892649.8 Ops/sec
querySelector(#id) 2017414.4 Ops/sec
querySelector(.id) 2925229.0 Ops/sec
querySelectorAll(#id) 1057425.4 Ops/sec
querySelectorAll(.id) 1350961.8 Ops/sec
jQuery(#id) 1292123.4 Ops/sec
jQuery(.id) 604299.5 Ops/sec
jQuery(tag#id) 349284.5 Ops/sec
jQuery(tag.id) 353708.4 Ops/sec
jQuery + getElementById 1414250.0 Ops/sec
jQuery + getElementsByClassName 513453.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