Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36
Chrome 68
Linux
Desktop
5 years ago
Test name Executions per second
getElementById() 2026377.5 Ops/sec
getElementsByClassName() 1500768.0 Ops/sec
getElementsByTagName() 1574000.0 Ops/sec
querySelector(#id) 1254725.4 Ops/sec
querySelector(.id) 1932905.6 Ops/sec
querySelectorAll(#id) 610118.2 Ops/sec
querySelectorAll(.id) 692136.2 Ops/sec
jQuery(#id) 652074.6 Ops/sec
jQuery(.id) 375461.1 Ops/sec
jQuery(tag#id) 201870.6 Ops/sec
jQuery(tag.id) 222066.1 Ops/sec
jQuery + getElementById 861782.8 Ops/sec
jQuery + getElementsByClassName 362650.8 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