Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0
Firefox 66
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 1553090.1 Ops/sec
getElementsByClassName() 1523405.9 Ops/sec
getElementsByTagName() 1753704.9 Ops/sec
querySelector(#id) 1629178.8 Ops/sec
querySelector(.id) 1670753.8 Ops/sec
querySelectorAll(#id) 742081.1 Ops/sec
querySelectorAll(.id) 796132.1 Ops/sec
jQuery(#id) 1771776.2 Ops/sec
jQuery(.id) 498211.8 Ops/sec
jQuery(tag#id) 321277.7 Ops/sec
jQuery(tag.id) 330850.4 Ops/sec
jQuery + getElementById 1372912.1 Ops/sec
jQuery + getElementsByClassName 522264.8 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