Run details:
Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
IE 11
Windows 7
Desktop
5 years ago
Test name Executions per second
getElementById() 791903.6 Ops/sec
getElementsByClassName() 579612.5 Ops/sec
getElementsByTagName() 568641.9 Ops/sec
querySelector(#id) 478426.7 Ops/sec
querySelector(.id) 328218.4 Ops/sec
querySelectorAll(#id) 225699.3 Ops/sec
querySelectorAll(.id) 225394.0 Ops/sec
jQuery(#id) 593688.6 Ops/sec
jQuery(.id) 235718.9 Ops/sec
jQuery(tag#id) 110277.5 Ops/sec
jQuery(tag.id) 112734.7 Ops/sec
jQuery + getElementById 647278.4 Ops/sec
jQuery + getElementsByClassName 169426.8 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