Run details:
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36
Chrome 56
Windows
Other
7 years ago
Test name Executions per second
getElementById() 2711205.2 Ops/sec
getElementsByClassName() 1975134.1 Ops/sec
getElementsByTagName() 2311531.8 Ops/sec
querySelector(#id) 2244596.2 Ops/sec
querySelector(.id) 668057.4 Ops/sec
querySelectorAll(#id) 1076226.0 Ops/sec
querySelectorAll(.id) 106578.6 Ops/sec
jQuery(#id) 1249594.9 Ops/sec
jQuery(.id) 739423.4 Ops/sec
jQuery(tag#id) 427771.9 Ops/sec
jQuery(tag.id) 80919.0 Ops/sec
jQuery + getElementById 1228796.0 Ops/sec
jQuery + getElementsByClassName 402941.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