Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36
Chrome 74
Linux
Desktop
5 years ago
Test name Executions per second
getElementById() 3004369.8 Ops/sec
getElementsByClassName() 2009814.6 Ops/sec
getElementsByTagName() 2209197.5 Ops/sec
querySelector(#id) 1678726.6 Ops/sec
querySelector(.id) 2255447.5 Ops/sec
querySelectorAll(#id) 627796.1 Ops/sec
querySelectorAll(.id) 758492.7 Ops/sec
jQuery(#id) 893321.2 Ops/sec
jQuery(.id) 454651.1 Ops/sec
jQuery(tag#id) 260191.3 Ops/sec
jQuery(tag.id) 285533.1 Ops/sec
jQuery + getElementById 1046841.0 Ops/sec
jQuery + getElementsByClassName 394710.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