Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:63.0) Gecko/20100101 Firefox/63.0
Firefox 63
Windows 7
Desktop
6 years ago
Test name Executions per second
getElementById() 1781170.8 Ops/sec
getElementsByClassName() 1840525.1 Ops/sec
getElementsByTagName() 1860755.9 Ops/sec
querySelector(#id) 1598053.9 Ops/sec
querySelector(.id) 1811496.8 Ops/sec
querySelectorAll(#id) 534953.1 Ops/sec
querySelectorAll(.id) 759991.1 Ops/sec
jQuery(#id) 1803488.5 Ops/sec
jQuery(.id) 549586.2 Ops/sec
jQuery(tag#id) 301834.6 Ops/sec
jQuery(tag.id) 343629.1 Ops/sec
jQuery + getElementById 1338069.8 Ops/sec
jQuery + getElementsByClassName 572113.4 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