Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:50.0) Gecko/20100101 Firefox/50.0
Firefox 50
Windows
Other
8 years ago
Test name Executions per second
getElementById() 10894881.0 Ops/sec
getElementsByClassName() 3854582.0 Ops/sec
getElementsByTagName() 4745259.0 Ops/sec
querySelector(#id) 5832082.5 Ops/sec
querySelector(.id) 404694.5 Ops/sec
querySelectorAll(#id) 1428195.5 Ops/sec
querySelectorAll(.id) 48188.3 Ops/sec
jQuery(#id) 3747657.8 Ops/sec
jQuery(.id) 404295.0 Ops/sec
jQuery(tag#id) 274058.9 Ops/sec
jQuery(tag.id) 39568.7 Ops/sec
jQuery + getElementById 5887213.0 Ops/sec
jQuery + getElementsByClassName 544576.5 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