Run details:
Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko
IE 11
Windows
Desktop
4 years ago
Test name Executions per second
getElementById() 1261977.5 Ops/sec
getElementsByClassName() 1101263.2 Ops/sec
getElementsByTagName() 1018870.6 Ops/sec
querySelector(#id) 832144.2 Ops/sec
querySelector(.id) 561773.2 Ops/sec
querySelectorAll(#id) 391754.2 Ops/sec
querySelectorAll(.id) 389914.8 Ops/sec
jQuery(#id) 892405.3 Ops/sec
jQuery(.id) 305919.0 Ops/sec
jQuery(tag#id) 161038.1 Ops/sec
jQuery(tag.id) 155408.0 Ops/sec
jQuery + getElementById 847762.4 Ops/sec
jQuery + getElementsByClassName 223544.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