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() 2247705.8 Ops/sec
getElementsByClassName() 1589880.8 Ops/sec
getElementsByTagName() 2084284.8 Ops/sec
querySelector(#id) 1390543.2 Ops/sec
querySelector(.id) 1308900.4 Ops/sec
querySelectorAll(#id) 772151.9 Ops/sec
querySelectorAll(.id) 930224.6 Ops/sec
jQuery(#id) 3744679.5 Ops/sec
jQuery(.id) 828325.3 Ops/sec
jQuery(tag#id) 480335.8 Ops/sec
jQuery(tag.id) 519384.2 Ops/sec
jQuery + getElementById 2184526.8 Ops/sec
jQuery + getElementsByClassName 717992.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


;