Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36
Chrome 68
Mac OS X 10.13.6
Desktop
6 years ago
Test name Executions per second
getElementById() 3572143.5 Ops/sec
getElementsByClassName() 2408772.5 Ops/sec
getElementsByTagName() 2946862.5 Ops/sec
querySelector(#id) 1992246.2 Ops/sec
querySelector(.id) 2672058.8 Ops/sec
querySelectorAll(#id) 845952.5 Ops/sec
querySelectorAll(.id) 1123493.8 Ops/sec
jQuery(#id) 1240702.4 Ops/sec
jQuery(.id) 537008.7 Ops/sec
jQuery(tag#id) 304074.6 Ops/sec
jQuery(tag.id) 325432.5 Ops/sec
jQuery + getElementById 1377489.6 Ops/sec
jQuery + getElementsByClassName 498215.0 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


;