Run details:
Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0
Firefox 70
Fedora
Desktop
5 years ago
Test name Executions per second
getElementById() 3306809.2 Ops/sec
getElementsByClassName() 1850195.2 Ops/sec
getElementsByTagName() 2576710.0 Ops/sec
querySelector(#id) 2326674.5 Ops/sec
querySelector(.id) 2105101.0 Ops/sec
querySelectorAll(#id) 843055.2 Ops/sec
querySelectorAll(.id) 849781.1 Ops/sec
jQuery(#id) 3372336.8 Ops/sec
jQuery(.id) 662746.2 Ops/sec
jQuery(tag#id) 393560.3 Ops/sec
jQuery(tag.id) 415425.3 Ops/sec
jQuery + getElementById 2222353.2 Ops/sec
jQuery + getElementsByClassName 545458.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