Run details:
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36 OPR/52.0.2871.99
Opera 52
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 1976609.4 Ops/sec
getElementsByClassName() 1316750.8 Ops/sec
getElementsByTagName() 1559202.5 Ops/sec
querySelector(#id) 1109644.4 Ops/sec
querySelector(.id) 1612880.6 Ops/sec
querySelectorAll(#id) 544026.6 Ops/sec
querySelectorAll(.id) 729140.6 Ops/sec
jQuery(#id) 486789.5 Ops/sec
jQuery(.id) 218762.7 Ops/sec
jQuery(tag#id) 130168.7 Ops/sec
jQuery(tag.id) 124791.8 Ops/sec
jQuery + getElementById 613434.7 Ops/sec
jQuery + getElementsByClassName 184220.6 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