Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36
Chrome 75
Mac OS X 10.14.3
Desktop
5 years ago
Test name Executions per second
getElementById() 2956073.0 Ops/sec
getElementsByClassName() 1783444.4 Ops/sec
getElementsByTagName() 2290688.8 Ops/sec
querySelector(#id) 1606864.1 Ops/sec
querySelector(.id) 2401019.0 Ops/sec
querySelectorAll(#id) 842046.8 Ops/sec
querySelectorAll(.id) 1005284.5 Ops/sec
jQuery(#id) 929097.6 Ops/sec
jQuery(.id) 467269.6 Ops/sec
jQuery(tag#id) 261349.3 Ops/sec
jQuery(tag.id) 278033.2 Ops/sec
jQuery + getElementById 1105050.5 Ops/sec
jQuery + getElementsByClassName 466093.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


;