Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.92 Safari/537.36
Chrome 69
Windows 7
Desktop
6 years ago
Test name Executions per second
getElementById() 2745171.5 Ops/sec
getElementsByClassName() 1778573.9 Ops/sec
getElementsByTagName() 2153268.2 Ops/sec
querySelector(#id) 1643423.6 Ops/sec
querySelector(.id) 2271800.2 Ops/sec
querySelectorAll(#id) 694942.1 Ops/sec
querySelectorAll(.id) 892431.5 Ops/sec
jQuery(#id) 1009710.4 Ops/sec
jQuery(.id) 482449.2 Ops/sec
jQuery(tag#id) 275231.0 Ops/sec
jQuery(tag.id) 280744.4 Ops/sec
jQuery + getElementById 1074972.6 Ops/sec
jQuery + getElementsByClassName 380379.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