Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:64.0) Gecko/20100101 Firefox/64.0
Firefox 64
Mac OS X 10.14
Desktop
5 years ago
Test name Executions per second
getElementById() 1957090.0 Ops/sec
getElementsByClassName() 2021059.5 Ops/sec
getElementsByTagName() 2340120.2 Ops/sec
querySelector(#id) 2075913.2 Ops/sec
querySelector(.id) 2115454.2 Ops/sec
querySelectorAll(#id) 649352.0 Ops/sec
querySelectorAll(.id) 908563.4 Ops/sec
jQuery(#id) 2045021.5 Ops/sec
jQuery(.id) 660421.2 Ops/sec
jQuery(tag#id) 327029.3 Ops/sec
jQuery(tag.id) 345283.0 Ops/sec
jQuery + getElementById 1734174.6 Ops/sec
jQuery + getElementsByClassName 644460.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