Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.11.1 Chrome/65.0.3325.230 Safari/537.36
Chrome 65
Linux
Desktop
6 years ago
Test name Executions per second
getElementById() 1809632.6 Ops/sec
getElementsByClassName() 1304034.9 Ops/sec
getElementsByTagName() 1477649.6 Ops/sec
querySelector(#id) 1170252.2 Ops/sec
querySelector(.id) 1497101.0 Ops/sec
querySelectorAll(#id) 522109.8 Ops/sec
querySelectorAll(.id) 600228.8 Ops/sec
jQuery(#id) 502725.1 Ops/sec
jQuery(.id) 261693.4 Ops/sec
jQuery(tag#id) 151532.8 Ops/sec
jQuery(tag.id) 158355.9 Ops/sec
jQuery + getElementById 677630.6 Ops/sec
jQuery + getElementsByClassName 225837.3 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