Run details:
Mozilla/5.0 (X11; Linux x86_64; rv:57.0) Gecko/20100101 Firefox/57.0
Firefox 57
Linux
Other
7 years ago
Test name Executions per second
getElementById() 2705515.2 Ops/sec
getElementsByClassName() 2235197.8 Ops/sec
getElementsByTagName() 2879303.5 Ops/sec
querySelector(#id) 2238445.5 Ops/sec
querySelector(.id) 382893.5 Ops/sec
querySelectorAll(#id) 704327.0 Ops/sec
querySelectorAll(.id) 37177.6 Ops/sec
jQuery(#id) 2070048.4 Ops/sec
jQuery(.id) 361058.9 Ops/sec
jQuery(tag#id) 200209.1 Ops/sec
jQuery(tag.id) 32407.0 Ops/sec
jQuery + getElementById 2016724.8 Ops/sec
jQuery + getElementsByClassName 311409.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


;