Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0
Firefox 62
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 1594416.4 Ops/sec
getElementsByClassName() 1605916.8 Ops/sec
getElementsByTagName() 1704405.6 Ops/sec
querySelector(#id) 1708961.6 Ops/sec
querySelector(.id) 1716330.5 Ops/sec
querySelectorAll(#id) 521080.1 Ops/sec
querySelectorAll(.id) 754230.8 Ops/sec
jQuery(#id) 1803020.9 Ops/sec
jQuery(.id) 497825.5 Ops/sec
jQuery(tag#id) 299076.4 Ops/sec
jQuery(tag.id) 343460.4 Ops/sec
jQuery + getElementById 1553133.8 Ops/sec
jQuery + getElementsByClassName 434257.5 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