Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:59.0) Gecko/20100101 Firefox/59.0
Firefox 59
Mac OS X 10.12
Other
6 years ago
Test name Executions per second
getElementById() 2829727.0 Ops/sec
getElementsByClassName() 2362932.5 Ops/sec
getElementsByTagName() 3009912.2 Ops/sec
querySelector(#id) 2336207.2 Ops/sec
querySelector(.id) 394105.6 Ops/sec
querySelectorAll(#id) 1039758.6 Ops/sec
querySelectorAll(.id) 44610.4 Ops/sec
jQuery(#id) 2606983.8 Ops/sec
jQuery(.id) 829143.1 Ops/sec
jQuery(tag#id) 477122.4 Ops/sec
jQuery(tag.id) 44673.0 Ops/sec
jQuery + getElementById 2157764.0 Ops/sec
jQuery + getElementsByClassName 630561.4 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