Run details:
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36 OPR/60.0.3255.109
Opera 60
Windows 7
Desktop
5 years ago
Test name Executions per second
getElementById() 1755274.2 Ops/sec
getElementsByClassName() 1054438.9 Ops/sec
getElementsByTagName() 1307364.2 Ops/sec
querySelector(#id) 825375.9 Ops/sec
querySelector(.id) 1328198.5 Ops/sec
querySelectorAll(#id) 347059.2 Ops/sec
querySelectorAll(.id) 491055.4 Ops/sec
jQuery(#id) 459676.8 Ops/sec
jQuery(.id) 244449.9 Ops/sec
jQuery(tag#id) 116522.7 Ops/sec
jQuery(tag.id) 122186.6 Ops/sec
jQuery + getElementById 447582.5 Ops/sec
jQuery + getElementsByClassName 197753.7 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