Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
Chrome 71
Mac OS X 10.14.2
Desktop
5 years ago
Test name Executions per second
getElementById() 3560061.0 Ops/sec
getElementsByClassName() 2248520.5 Ops/sec
getElementsByTagName() 2788544.0 Ops/sec
querySelector(#id) 2003894.2 Ops/sec
querySelector(.id) 2897572.2 Ops/sec
querySelectorAll(#id) 763101.6 Ops/sec
querySelectorAll(.id) 1041429.8 Ops/sec
jQuery(#id) 1251726.9 Ops/sec
jQuery(.id) 636953.4 Ops/sec
jQuery(tag#id) 342358.2 Ops/sec
jQuery(tag.id) 365513.5 Ops/sec
jQuery + getElementById 1397753.9 Ops/sec
jQuery + getElementsByClassName 506370.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


;