Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0
Firefox 66
Windows 7
Desktop
5 years ago
Test name Executions per second
getElementById() 1216276.6 Ops/sec
getElementsByClassName() 1210003.6 Ops/sec
getElementsByTagName() 1412661.8 Ops/sec
querySelector(#id) 1460588.9 Ops/sec
querySelector(.id) 1439372.0 Ops/sec
querySelectorAll(#id) 509717.5 Ops/sec
querySelectorAll(.id) 548935.8 Ops/sec
jQuery(#id) 1258755.2 Ops/sec
jQuery(.id) 285989.6 Ops/sec
jQuery(tag#id) 133785.9 Ops/sec
jQuery(tag.id) 138555.4 Ops/sec
jQuery + getElementById 920750.0 Ops/sec
jQuery + getElementsByClassName 304347.9 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