Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0
Firefox 66
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 921407.6 Ops/sec
getElementsByClassName() 883734.2 Ops/sec
getElementsByTagName() 881492.2 Ops/sec
querySelector(#id) 887829.2 Ops/sec
querySelector(.id) 1186584.5 Ops/sec
querySelectorAll(#id) 525714.1 Ops/sec
querySelectorAll(.id) 694846.9 Ops/sec
jQuery(#id) 975285.9 Ops/sec
jQuery(.id) 369933.5 Ops/sec
jQuery(tag#id) 232818.8 Ops/sec
jQuery(tag.id) 303952.7 Ops/sec
jQuery + getElementById 862071.1 Ops/sec
jQuery + getElementsByClassName 320421.7 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