Run details:
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0
Firefox 50
Windows 7
Other
8 years ago
Test name Executions per second
getElementById() 7679070.5 Ops/sec
getElementsByClassName() 3246050.0 Ops/sec
getElementsByTagName() 4591893.0 Ops/sec
querySelector(#id) 4204931.5 Ops/sec
querySelector(.id) 357452.2 Ops/sec
querySelectorAll(#id) 1161654.2 Ops/sec
querySelectorAll(.id) 46908.8 Ops/sec
jQuery(#id) 1093181.5 Ops/sec
jQuery(.id) 205803.7 Ops/sec
jQuery(tag#id) 185085.0 Ops/sec
jQuery(tag.id) 35207.4 Ops/sec
jQuery + getElementById 2170427.0 Ops/sec
jQuery + getElementsByClassName 223234.6 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