Run details:
Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko
IE 11
Windows
Other
8 years ago
Test name Executions per second
getElementById() 1489937.9 Ops/sec
getElementsByClassName() 1092467.2 Ops/sec
getElementsByTagName() 1131084.2 Ops/sec
querySelector(#id) 919821.6 Ops/sec
querySelector(.id) 140735.2 Ops/sec
querySelectorAll(#id) 38832.8 Ops/sec
querySelectorAll(.id) 31946.5 Ops/sec
jQuery(#id) 979102.3 Ops/sec
jQuery(.id) 373938.1 Ops/sec
jQuery(tag#id) 32366.2 Ops/sec
jQuery(tag.id) 29097.1 Ops/sec
jQuery + getElementById 976078.9 Ops/sec
jQuery + getElementsByClassName 233923.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