Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36 OPR/54.0.2952.64
Opera 54
Windows 7
Desktop
5 years ago
Test name Executions per second
getElementById() 2231321.8 Ops/sec
getElementsByClassName() 1439592.2 Ops/sec
getElementsByTagName() 1478103.1 Ops/sec
querySelector(#id) 1319301.2 Ops/sec
querySelector(.id) 1774132.1 Ops/sec
querySelectorAll(#id) 556152.9 Ops/sec
querySelectorAll(.id) 702386.5 Ops/sec
jQuery(#id) 567463.9 Ops/sec
jQuery(.id) 179367.5 Ops/sec
jQuery(tag#id) 118377.2 Ops/sec
jQuery(tag.id) 109913.4 Ops/sec
jQuery + getElementById 755311.8 Ops/sec
jQuery + getElementsByClassName 213874.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


;