Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36
Chrome 79
Windows 7
Desktop
4 years ago
Test name Executions per second
getElementById() 2688884.5 Ops/sec
getElementsByClassName() 1560576.4 Ops/sec
getElementsByTagName() 2122886.2 Ops/sec
querySelector(#id) 1324755.0 Ops/sec
querySelector(.id) 1915034.1 Ops/sec
querySelectorAll(#id) 699816.3 Ops/sec
querySelectorAll(.id) 877997.4 Ops/sec
jQuery(#id) 511692.2 Ops/sec
jQuery(.id) 189097.5 Ops/sec
jQuery(tag#id) 127213.7 Ops/sec
jQuery(tag.id) 101338.1 Ops/sec
jQuery + getElementById 842199.7 Ops/sec
jQuery + getElementsByClassName 230112.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