Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36
Chrome 62
Windows
Other
7 years ago
Test name Executions per second
getElementById() 921622.4 Ops/sec
getElementsByClassName() 683495.0 Ops/sec
getElementsByTagName() 804336.5 Ops/sec
querySelector(#id) 829701.6 Ops/sec
querySelector(.id) 182751.3 Ops/sec
querySelectorAll(#id) 354646.9 Ops/sec
querySelectorAll(.id) 28545.1 Ops/sec
jQuery(#id) 362295.7 Ops/sec
jQuery(.id) 220532.8 Ops/sec
jQuery(tag#id) 130322.1 Ops/sec
jQuery(tag.id) 26351.6 Ops/sec
jQuery + getElementById 396666.7 Ops/sec
jQuery + getElementsByClassName 141169.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