Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36
Chrome 73
Windows 7
Desktop
5 years ago
Test name Executions per second
getElementById() 944311.4 Ops/sec
getElementsByClassName() 854309.4 Ops/sec
getElementsByTagName() 1047480.5 Ops/sec
querySelector(#id) 450932.8 Ops/sec
querySelector(.id) 698492.6 Ops/sec
querySelectorAll(#id) 247608.2 Ops/sec
querySelectorAll(.id) 273517.3 Ops/sec
jQuery(#id) 259683.8 Ops/sec
jQuery(.id) 214076.9 Ops/sec
jQuery(tag#id) 70770.2 Ops/sec
jQuery(tag.id) 102025.2 Ops/sec
jQuery + getElementById 544809.2 Ops/sec
jQuery + getElementsByClassName 146694.2 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