Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36
Chrome 69
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 2025784.2 Ops/sec
getElementsByClassName() 1324772.5 Ops/sec
getElementsByTagName() 1573576.4 Ops/sec
querySelector(#id) 1263699.5 Ops/sec
querySelector(.id) 1726684.5 Ops/sec
querySelectorAll(#id) 589370.0 Ops/sec
querySelectorAll(.id) 688196.9 Ops/sec
jQuery(#id) 578956.5 Ops/sec
jQuery(.id) 338646.2 Ops/sec
jQuery(tag#id) 192146.0 Ops/sec
jQuery(tag.id) 210785.4 Ops/sec
jQuery + getElementById 806664.1 Ops/sec
jQuery + getElementsByClassName 245320.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


;