Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/71.0.3578.98 Chrome/71.0.3578.98 Safari/537.36
Chromium 71
Ubuntu
Desktop
5 years ago
Test name Executions per second
getElementById() 4210316.5 Ops/sec
getElementsByClassName() 2833658.5 Ops/sec
getElementsByTagName() 3261231.8 Ops/sec
querySelector(#id) 2571024.5 Ops/sec
querySelector(.id) 3263019.8 Ops/sec
querySelectorAll(#id) 1010637.0 Ops/sec
querySelectorAll(.id) 1232953.2 Ops/sec
jQuery(#id) 1460187.9 Ops/sec
jQuery(.id) 795950.5 Ops/sec
jQuery(tag#id) 464977.0 Ops/sec
jQuery(tag.id) 478016.9 Ops/sec
jQuery + getElementById 1635812.0 Ops/sec
jQuery + getElementsByClassName 698138.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