Run details:
Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36
Chrome 80
Windows 8
Desktop
4 years ago
Test name Executions per second
getElementById() 2359546.8 Ops/sec
getElementsByClassName() 1504634.6 Ops/sec
getElementsByTagName() 1792168.5 Ops/sec
querySelector(#id) 1453893.5 Ops/sec
querySelector(.id) 2649425.8 Ops/sec
querySelectorAll(#id) 879090.7 Ops/sec
querySelectorAll(.id) 1318679.8 Ops/sec
jQuery(#id) 1360237.4 Ops/sec
jQuery(.id) 112276.5 Ops/sec
jQuery(tag#id) 98967.9 Ops/sec
jQuery(tag.id) 102534.0 Ops/sec
jQuery + getElementById 1076792.2 Ops/sec
jQuery + getElementsByClassName 317681.6 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


;