Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.75 Safari/537.36
Chrome 68
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 3140155.5 Ops/sec
getElementsByClassName() 2048004.2 Ops/sec
getElementsByTagName() 2477809.8 Ops/sec
querySelector(#id) 1895112.1 Ops/sec
querySelector(.id) 2518555.5 Ops/sec
querySelectorAll(#id) 860503.6 Ops/sec
querySelectorAll(.id) 1022062.8 Ops/sec
jQuery(#id) 975806.9 Ops/sec
jQuery(.id) 435106.3 Ops/sec
jQuery(tag#id) 297603.3 Ops/sec
jQuery(tag.id) 306896.6 Ops/sec
jQuery + getElementById 1235345.5 Ops/sec
jQuery + getElementsByClassName 427569.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