Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
Chrome 71
Windows 7
Desktop
5 years ago
Test name Executions per second
getElementById() 3553777.0 Ops/sec
getElementsByClassName() 2296582.8 Ops/sec
getElementsByTagName() 2719985.8 Ops/sec
querySelector(#id) 2089454.9 Ops/sec
querySelector(.id) 2860282.2 Ops/sec
querySelectorAll(#id) 788940.9 Ops/sec
querySelectorAll(.id) 1040718.5 Ops/sec
jQuery(#id) 1132485.1 Ops/sec
jQuery(.id) 592137.5 Ops/sec
jQuery(tag#id) 334251.7 Ops/sec
jQuery(tag.id) 340083.9 Ops/sec
jQuery + getElementById 1235294.0 Ops/sec
jQuery + getElementsByClassName 524235.8 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