Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36
Chrome 68
Mac OS X 10.13.6
Desktop
6 years ago
Test name Executions per second
getElementById() 3470093.8 Ops/sec
getElementsByClassName() 2318024.2 Ops/sec
getElementsByTagName() 2819294.8 Ops/sec
querySelector(#id) 1995805.8 Ops/sec
querySelector(.id) 2832650.0 Ops/sec
querySelectorAll(#id) 755916.4 Ops/sec
querySelectorAll(.id) 924329.8 Ops/sec
jQuery(#id) 1247554.0 Ops/sec
jQuery(.id) 569547.8 Ops/sec
jQuery(tag#id) 314079.9 Ops/sec
jQuery(tag.id) 321961.0 Ops/sec
jQuery + getElementById 1311993.1 Ops/sec
jQuery + getElementsByClassName 486484.1 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