Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36
Chrome 69
Mac OS X 10.14.0
Desktop
6 years ago
Test name Executions per second
getElementById() 3311649.0 Ops/sec
getElementsByClassName() 2079948.8 Ops/sec
getElementsByTagName() 2618585.2 Ops/sec
querySelector(#id) 1823377.9 Ops/sec
querySelector(.id) 2735407.8 Ops/sec
querySelectorAll(#id) 776876.1 Ops/sec
querySelectorAll(.id) 962517.8 Ops/sec
jQuery(#id) 1120798.4 Ops/sec
jQuery(.id) 518108.0 Ops/sec
jQuery(tag#id) 313190.0 Ops/sec
jQuery(tag.id) 329050.2 Ops/sec
jQuery + getElementById 1229823.6 Ops/sec
jQuery + getElementsByClassName 394587.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