Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/602.4.8 (KHTML, like Gecko) Version/10.0.3 Safari/602.4.8
Safari 10
Mac OS X 10.12.3
Other
7 years ago
Test name Executions per second
getElementById() 4407120.5 Ops/sec
getElementsByClassName() 2937119.0 Ops/sec
getElementsByTagName() 3840263.2 Ops/sec
querySelector(#id) 3181709.8 Ops/sec
querySelector(.id) 771997.3 Ops/sec
querySelectorAll(#id) 2251863.8 Ops/sec
querySelectorAll(.id) 88189.2 Ops/sec
jQuery(#id) 2169815.2 Ops/sec
jQuery(.id) 1226219.5 Ops/sec
jQuery(tag#id) 836571.4 Ops/sec
jQuery(tag.id) 78541.2 Ops/sec
jQuery + getElementById 2004796.6 Ops/sec
jQuery + getElementsByClassName 836881.5 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


;