Run details:
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.87 Safari/537.36
Chrome 54
Windows
Other
8 years ago
Test name Executions per second
getElementById() 2513816.5 Ops/sec
getElementsByClassName() 2077709.9 Ops/sec
getElementsByTagName() 2733386.8 Ops/sec
querySelector(#id) 2439750.2 Ops/sec
querySelector(.id) 688505.4 Ops/sec
querySelectorAll(#id) 1158250.2 Ops/sec
querySelectorAll(.id) 100137.9 Ops/sec
jQuery(#id) 961991.8 Ops/sec
jQuery(.id) 639896.5 Ops/sec
jQuery(tag#id) 421366.1 Ops/sec
jQuery(tag.id) 58600.1 Ops/sec
jQuery + getElementById 962398.2 Ops/sec
jQuery + getElementsByClassName 309552.2 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