Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0
Firefox 72
Windows
Desktop
4 years ago
Test name Executions per second
getElementById() 871180.2 Ops/sec
getElementsByClassName() 591463.8 Ops/sec
getElementsByTagName() 671468.7 Ops/sec
querySelector(#id) 404433.9 Ops/sec
querySelector(.id) 614375.4 Ops/sec
querySelectorAll(#id) 163886.1 Ops/sec
querySelectorAll(.id) 194444.1 Ops/sec
jQuery(#id) 922955.0 Ops/sec
jQuery(.id) 98058.8 Ops/sec
jQuery(tag#id) 56927.7 Ops/sec
jQuery(tag.id) 57633.5 Ops/sec
jQuery + getElementById 558505.3 Ops/sec
jQuery + getElementsByClassName 87363.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