Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36 FirePHP/4Chrome
Chrome 69
Mac OS X 10.13.6
Desktop
6 years ago
Test name Executions per second
getElementById() 2502720.5 Ops/sec
getElementsByClassName() 1736918.4 Ops/sec
getElementsByTagName() 2156091.2 Ops/sec
querySelector(#id) 1240761.5 Ops/sec
querySelector(.id) 2077650.1 Ops/sec
querySelectorAll(#id) 640962.3 Ops/sec
querySelectorAll(.id) 843846.2 Ops/sec
jQuery(#id) 873039.1 Ops/sec
jQuery(.id) 405574.1 Ops/sec
jQuery(tag#id) 241005.6 Ops/sec
jQuery(tag.id) 130449.6 Ops/sec
jQuery + getElementById 951020.5 Ops/sec
jQuery + getElementsByClassName 253064.0 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