Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0
Firefox 57
Windows
Other
7 years ago
Test name Executions per second
getElementById() 2745886.2 Ops/sec
getElementsByClassName() 2138531.0 Ops/sec
getElementsByTagName() 2996110.8 Ops/sec
querySelector(#id) 2282461.5 Ops/sec
querySelector(.id) 364749.4 Ops/sec
querySelectorAll(#id) 1113685.8 Ops/sec
querySelectorAll(.id) 52305.9 Ops/sec
jQuery(#id) 2696322.5 Ops/sec
jQuery(.id) 716532.5 Ops/sec
jQuery(tag#id) 465817.3 Ops/sec
jQuery(tag.id) 49930.9 Ops/sec
jQuery + getElementById 2436737.5 Ops/sec
jQuery + getElementsByClassName 507089.5 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


;