Run details:
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:49.0) Gecko/20100101 Firefox/49.0
Firefox 49
Windows 7
Other
7 years ago
Test name Executions per second
getElementById 5029971.0 Ops/sec
getElementsByClassName 1860466.0 Ops/sec
querySelector 2425123.0 Ops/sec
querySelectorAll 782348.1 Ops/sec
jQuery 978337.4 Ops/sec
jQuery + getElementById 2988407.0 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