Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0
Firefox 61
Windows 7
Desktop
6 years ago
Test name Executions per second
getElementById() 2440350.2 Ops/sec
getElementsByClassName() 2098860.0 Ops/sec
getElementsByTagName() 2455202.5 Ops/sec
querySelector(#id) 2589443.5 Ops/sec
querySelector(.id) 2531006.8 Ops/sec
querySelectorAll(#id) 624384.4 Ops/sec
querySelectorAll(.id) 995087.5 Ops/sec
jQuery(#id) 2577569.8 Ops/sec
jQuery(.id) 381951.0 Ops/sec
jQuery(tag#id) 199667.9 Ops/sec
jQuery(tag.id) 214047.1 Ops/sec
jQuery + getElementById 2004520.2 Ops/sec
jQuery + getElementsByClassName 397629.8 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