Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Safari/537.36
Chrome 74
Linux
Desktop
5 years ago
Test name Executions per second
getElementById() 3170652.0 Ops/sec
getElementsByClassName() 2471304.0 Ops/sec
getElementsByTagName() 1939457.8 Ops/sec
querySelector(#id) 2135403.2 Ops/sec
querySelector(.id) 2925293.0 Ops/sec
querySelectorAll(#id) 888309.1 Ops/sec
querySelectorAll(.id) 1179395.2 Ops/sec
jQuery(#id) 1214663.5 Ops/sec
jQuery(.id) 636911.6 Ops/sec
jQuery(tag#id) 378221.7 Ops/sec
jQuery(tag.id) 392267.2 Ops/sec
jQuery + getElementById 1507326.1 Ops/sec
jQuery + getElementsByClassName 579110.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