Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36
Chrome 75
Mac OS X 10.14.5
Desktop
5 years ago
Test name Executions per second
getElementById() 4925596.0 Ops/sec
getElementsByClassName() 2908074.8 Ops/sec
getElementsByTagName() 3757919.8 Ops/sec
querySelector(#id) 2442794.8 Ops/sec
querySelector(.id) 3870945.0 Ops/sec
querySelectorAll(#id) 1374853.9 Ops/sec
querySelectorAll(.id) 1808161.4 Ops/sec
jQuery(#id) 1543222.5 Ops/sec
jQuery(.id) 756848.0 Ops/sec
jQuery(tag#id) 477108.5 Ops/sec
jQuery(tag.id) 461851.8 Ops/sec
jQuery + getElementById 1888186.4 Ops/sec
jQuery + getElementsByClassName 703901.7 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


;