Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36
Chrome 74
Mac OS X 10.14.4
Desktop
5 years ago
Test name Executions per second
getElementById() 6151393.0 Ops/sec
getElementsByClassName() 3786192.5 Ops/sec
getElementsByTagName() 4791966.0 Ops/sec
querySelector(#id) 3302660.5 Ops/sec
querySelector(.id) 4789118.5 Ops/sec
querySelectorAll(#id) 1300402.0 Ops/sec
querySelectorAll(.id) 1613324.1 Ops/sec
jQuery(#id) 1883257.1 Ops/sec
jQuery(.id) 975752.2 Ops/sec
jQuery(tag#id) 493279.6 Ops/sec
jQuery(tag.id) 528255.9 Ops/sec
jQuery + getElementById 2060995.0 Ops/sec
jQuery + getElementsByClassName 874500.5 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