Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36
Chrome 57
Windows
Other
7 years ago
Test name Executions per second
getElementById() 2513142.2 Ops/sec
getElementsByClassName() 1793369.2 Ops/sec
getElementsByTagName() 2189121.8 Ops/sec
querySelector(#id) 2115782.2 Ops/sec
querySelector(.id) 552919.0 Ops/sec
querySelectorAll(#id) 1035543.4 Ops/sec
querySelectorAll(.id) 78669.5 Ops/sec
jQuery(#id) 1070672.0 Ops/sec
jQuery(.id) 566475.3 Ops/sec
jQuery(tag#id) 353169.1 Ops/sec
jQuery(tag.id) 62005.5 Ops/sec
jQuery + getElementById 1152555.5 Ops/sec
jQuery + getElementsByClassName 363867.1 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