Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36
Chrome 73
Linux
Desktop
5 years ago
Test name Executions per second
getElementById() 4477230.0 Ops/sec
getElementsByClassName() 2961442.5 Ops/sec
getElementsByTagName() 3450458.2 Ops/sec
querySelector(#id) 2502841.5 Ops/sec
querySelector(.id) 3456045.0 Ops/sec
querySelectorAll(#id) 1025804.6 Ops/sec
querySelectorAll(.id) 1273230.1 Ops/sec
jQuery(#id) 1455791.6 Ops/sec
jQuery(.id) 779418.9 Ops/sec
jQuery(tag#id) 397188.6 Ops/sec
jQuery(tag.id) 420449.7 Ops/sec
jQuery + getElementById 1692598.5 Ops/sec
jQuery + getElementsByClassName 686283.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