Run details:
Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36
Chrome 67
Windows 8.1
Desktop
6 years ago
Test name Executions per second
getElementById() 2157264.5 Ops/sec
getElementsByClassName() 1442024.8 Ops/sec
getElementsByTagName() 1648876.2 Ops/sec
querySelector(#id) 1296205.1 Ops/sec
querySelector(.id) 1800764.6 Ops/sec
querySelectorAll(#id) 632683.4 Ops/sec
querySelectorAll(.id) 753824.2 Ops/sec
jQuery(#id) 809684.7 Ops/sec
jQuery(.id) 321717.4 Ops/sec
jQuery(tag#id) 210076.0 Ops/sec
jQuery(tag.id) 212397.4 Ops/sec
jQuery + getElementById 855546.8 Ops/sec
jQuery + getElementsByClassName 293922.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


;