Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36
Chrome 74
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 2110312.2 Ops/sec
getElementsByClassName() 1265321.8 Ops/sec
getElementsByTagName() 676516.4 Ops/sec
querySelector(#id) 984143.6 Ops/sec
querySelector(.id) 682761.7 Ops/sec
querySelectorAll(#id) 238618.3 Ops/sec
querySelectorAll(.id) 298107.2 Ops/sec
jQuery(#id) 338489.3 Ops/sec
jQuery(.id) 152901.8 Ops/sec
jQuery(tag#id) 95247.9 Ops/sec
jQuery(tag.id) 101172.1 Ops/sec
jQuery + getElementById 405546.6 Ops/sec
jQuery + getElementsByClassName 161922.2 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