Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
Chrome 67
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 3238631.0 Ops/sec
getElementsByClassName() 1797469.0 Ops/sec
getElementsByTagName() 2266133.0 Ops/sec
querySelector(#id) 1700000.0 Ops/sec
querySelector(.id) 2446342.0 Ops/sec
querySelectorAll(#id) 706777.8 Ops/sec
querySelectorAll(.id) 889082.0 Ops/sec
jQuery(#id) 813448.8 Ops/sec
jQuery(.id) 404373.7 Ops/sec
jQuery(tag#id) 251587.0 Ops/sec
jQuery(tag.id) 264608.1 Ops/sec
jQuery + getElementById 972701.9 Ops/sec
jQuery + getElementsByClassName 322686.3 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