Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36
Chrome 74
Mac OS X 10.14.3
Desktop
5 years ago
Test name Executions per second
getElementById() 4334631.0 Ops/sec
getElementsByClassName() 2662471.0 Ops/sec
getElementsByTagName() 3307646.5 Ops/sec
querySelector(#id) 2354139.8 Ops/sec
querySelector(.id) 3452962.8 Ops/sec
querySelectorAll(#id) 953584.2 Ops/sec
querySelectorAll(.id) 1267538.2 Ops/sec
jQuery(#id) 1456072.8 Ops/sec
jQuery(.id) 656234.7 Ops/sec
jQuery(tag#id) 365997.1 Ops/sec
jQuery(tag.id) 396441.0 Ops/sec
jQuery + getElementById 1623583.2 Ops/sec
jQuery + getElementsByClassName 651665.9 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