Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36
Chrome 62
Mac OS X 10.12.3
Other
6 years ago
Test name Executions per second
getElementById() 2650409.8 Ops/sec
getElementsByClassName() 1688326.5 Ops/sec
getElementsByTagName() 2126021.8 Ops/sec
querySelector(#id) 2216907.0 Ops/sec
querySelector(.id) 615316.2 Ops/sec
querySelectorAll(#id) 866958.0 Ops/sec
querySelectorAll(.id) 66946.7 Ops/sec
jQuery(#id) 888862.1 Ops/sec
jQuery(.id) 495340.8 Ops/sec
jQuery(tag#id) 280934.2 Ops/sec
jQuery(tag.id) 57052.5 Ops/sec
jQuery + getElementById 877688.5 Ops/sec
jQuery + getElementsByClassName 337416.1 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


;