Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36
Chrome 63
Mac OS X 10.11.6
Other
2025 years ago
Test name Executions per second
getElementById() 3355641.5 Ops/sec
getElementsByClassName() 2169278.5 Ops/sec
getElementsByTagName() 2721737.2 Ops/sec
querySelector(#id) 2871783.8 Ops/sec
querySelector(.id) 680660.0 Ops/sec
querySelectorAll(#id) 1206048.2 Ops/sec
querySelectorAll(.id) 88234.5 Ops/sec
jQuery(#id) 1216483.6 Ops/sec
jQuery(.id) 635190.5 Ops/sec
jQuery(tag#id) 408498.1 Ops/sec
jQuery(tag.id) 68603.5 Ops/sec
jQuery + getElementById 1313784.5 Ops/sec
jQuery + getElementsByClassName 378613.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


;