Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0
Firefox 56
Windows
Other
7 years ago
Test name Executions per second
getElementById() 3137416.2 Ops/sec
getElementsByClassName() 2561613.0 Ops/sec
getElementsByTagName() 3234076.8 Ops/sec
querySelector(#id) 2463315.5 Ops/sec
querySelector(.id) 402540.2 Ops/sec
querySelectorAll(#id) 1225544.4 Ops/sec
querySelectorAll(.id) 55904.1 Ops/sec
jQuery(#id) 2743389.2 Ops/sec
jQuery(.id) 916505.2 Ops/sec
jQuery(tag#id) 497691.8 Ops/sec
jQuery(tag.id) 53519.2 Ops/sec
jQuery + getElementById 2482026.0 Ops/sec
jQuery + getElementsByClassName 629535.0 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