Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/604.5.6 (KHTML, like Gecko) Version/11.0.3 Safari/604.5.6
Safari 11
Mac OS X 10.13.3
Other
2025 years ago
Test name Executions per second
getElementById() 4465266.0 Ops/sec
getElementsByClassName() 3437067.5 Ops/sec
getElementsByTagName() 3943546.8 Ops/sec
querySelector(#id) 3408833.5 Ops/sec
querySelector(.id) 876032.3 Ops/sec
querySelectorAll(#id) 2410557.5 Ops/sec
querySelectorAll(.id) 108813.9 Ops/sec
jQuery(#id) 2386298.8 Ops/sec
jQuery(.id) 1345905.6 Ops/sec
jQuery(tag#id) 939333.2 Ops/sec
jQuery(tag.id) 97928.5 Ops/sec
jQuery + getElementById 2107137.8 Ops/sec
jQuery + getElementsByClassName 1121827.2 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