Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0
Firefox 72
Windows 7
Desktop
4 years ago
Test name Executions per second
getElementById() 3137341.8 Ops/sec
getElementsByClassName() 1704057.0 Ops/sec
getElementsByTagName() 2548759.8 Ops/sec
querySelector(#id) 2607027.2 Ops/sec
querySelector(.id) 2613949.2 Ops/sec
querySelectorAll(#id) 946266.9 Ops/sec
querySelectorAll(.id) 1066257.6 Ops/sec
jQuery(#id) 3457619.5 Ops/sec
jQuery(.id) 534250.9 Ops/sec
jQuery(tag#id) 292727.5 Ops/sec
jQuery(tag.id) 301411.8 Ops/sec
jQuery + getElementById 2203552.2 Ops/sec
jQuery + getElementsByClassName 474136.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