Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0
Firefox 61
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 2865486.5 Ops/sec
getElementsByClassName() 2569170.2 Ops/sec
getElementsByTagName() 3010473.5 Ops/sec
querySelector(#id) 3026524.0 Ops/sec
querySelector(.id) 2952288.8 Ops/sec
querySelectorAll(#id) 770253.8 Ops/sec
querySelectorAll(.id) 1175561.5 Ops/sec
jQuery(#id) 2908841.5 Ops/sec
jQuery(.id) 793872.5 Ops/sec
jQuery(tag#id) 397295.8 Ops/sec
jQuery(tag.id) 450845.5 Ops/sec
jQuery + getElementById 2393759.5 Ops/sec
jQuery + getElementsByClassName 669975.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