Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36
Chrome 70
Mac OS X 10.13.6
Desktop
6 years ago
Test name Executions per second
getElementById() 3583726.0 Ops/sec
getElementsByClassName() 2435068.2 Ops/sec
getElementsByTagName() 2971625.8 Ops/sec
querySelector(#id) 2163718.5 Ops/sec
querySelector(.id) 3030554.0 Ops/sec
querySelectorAll(#id) 801052.1 Ops/sec
querySelectorAll(.id) 977685.4 Ops/sec
jQuery(#id) 1388884.9 Ops/sec
jQuery(.id) 649565.5 Ops/sec
jQuery(tag#id) 340607.4 Ops/sec
jQuery(tag.id) 343033.7 Ops/sec
jQuery + getElementById 1444551.6 Ops/sec
jQuery + getElementsByClassName 483032.7 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


;