Run details:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0
Firefox 58
Ubuntu
Other
2025 years ago
Test name Executions per second
getElementById() 2658327.5 Ops/sec
getElementsByClassName() 2335100.0 Ops/sec
getElementsByTagName() 2949052.0 Ops/sec
querySelector(#id) 2122057.8 Ops/sec
querySelector(.id) 381178.3 Ops/sec
querySelectorAll(#id) 1062093.6 Ops/sec
querySelectorAll(.id) 42784.8 Ops/sec
jQuery(#id) 2606786.2 Ops/sec
jQuery(.id) 864683.3 Ops/sec
jQuery(tag#id) 435331.1 Ops/sec
jQuery(tag.id) 43139.7 Ops/sec
jQuery + getElementById 2268532.8 Ops/sec
jQuery + getElementsByClassName 594758.9 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


;