Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/604.4.7 (KHTML, like Gecko) Version/11.0.2 Safari/604.4.7
Safari 11
Mac OS X 10.11.6
Other
2025 years ago
Test name Executions per second
getElementById() 3819153.8 Ops/sec
getElementsByClassName() 2769508.5 Ops/sec
getElementsByTagName() 3186140.8 Ops/sec
querySelector(#id) 2726589.5 Ops/sec
querySelector(.id) 570219.6 Ops/sec
querySelectorAll(#id) 1998348.4 Ops/sec
querySelectorAll(.id) 82742.1 Ops/sec
jQuery(#id) 1982298.0 Ops/sec
jQuery(.id) 1163432.8 Ops/sec
jQuery(tag#id) 834854.3 Ops/sec
jQuery(tag.id) 73368.1 Ops/sec
jQuery + getElementById 1862412.1 Ops/sec
jQuery + getElementsByClassName 874936.9 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