Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36
Chrome 67
Mac OS X 10.13.1
Desktop
6 years ago
Test name Executions per second
getElementById() 2158656.5 Ops/sec
getElementsByClassName() 1381133.4 Ops/sec
getElementsByTagName() 1756707.8 Ops/sec
querySelector(#id) 1269740.5 Ops/sec
querySelector(.id) 1709624.6 Ops/sec
querySelectorAll(#id) 461213.9 Ops/sec
querySelectorAll(.id) 629227.6 Ops/sec
jQuery(#id) 723370.4 Ops/sec
jQuery(.id) 258710.3 Ops/sec
jQuery(tag#id) 156442.2 Ops/sec
jQuery(tag.id) 168989.5 Ops/sec
jQuery + getElementById 749501.8 Ops/sec
jQuery + getElementsByClassName 249359.9 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


;