Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36
Chrome 73
Linux
Desktop
5 years ago
Test name Executions per second
getElementById() 2307618.8 Ops/sec
getElementsByClassName() 1423020.2 Ops/sec
getElementsByTagName() 1672929.5 Ops/sec
querySelector(#id) 1141639.4 Ops/sec
querySelector(.id) 1845967.5 Ops/sec
querySelectorAll(#id) 404317.8 Ops/sec
querySelectorAll(.id) 543960.7 Ops/sec
jQuery(#id) 484576.2 Ops/sec
jQuery(.id) 256162.8 Ops/sec
jQuery(tag#id) 140624.7 Ops/sec
jQuery(tag.id) 146099.3 Ops/sec
jQuery + getElementById 750964.8 Ops/sec
jQuery + getElementsByClassName 217162.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