Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.108 Safari/537.36
Chrome 74
Mac OS X 10.12.6
Desktop
5 years ago
Test name Executions per second
getElementById() 3723453.5 Ops/sec
getElementsByClassName() 2199210.0 Ops/sec
getElementsByTagName() 2676996.2 Ops/sec
querySelector(#id) 1943276.9 Ops/sec
querySelector(.id) 3048258.5 Ops/sec
querySelectorAll(#id) 769734.7 Ops/sec
querySelectorAll(.id) 1029595.2 Ops/sec
jQuery(#id) 1143604.0 Ops/sec
jQuery(.id) 568668.8 Ops/sec
jQuery(tag#id) 309237.7 Ops/sec
jQuery(tag.id) 346872.7 Ops/sec
jQuery + getElementById 1368605.9 Ops/sec
jQuery + getElementsByClassName 570706.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