Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36
Chrome 60
Mac OS X 10.12.6
Other
7 years ago
Test name Executions per second
getElementById() 2670392.5 Ops/sec
getElementsByClassName() 1704319.4 Ops/sec
getElementsByTagName() 2166319.5 Ops/sec
querySelector(#id) 2287205.5 Ops/sec
querySelector(.id) 582693.6 Ops/sec
querySelectorAll(#id) 942493.6 Ops/sec
querySelectorAll(.id) 82288.2 Ops/sec
jQuery(#id) 1074517.9 Ops/sec
jQuery(.id) 572281.1 Ops/sec
jQuery(tag#id) 365207.8 Ops/sec
jQuery(tag.id) 64165.3 Ops/sec
jQuery + getElementById 1164517.0 Ops/sec
jQuery + getElementsByClassName 356546.3 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


;