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() 2073429.6 Ops/sec
getElementsByClassName() 1153575.5 Ops/sec
getElementsByTagName() 1747029.1 Ops/sec
querySelector(#id) 1119578.8 Ops/sec
querySelector(.id) 1762096.4 Ops/sec
querySelectorAll(#id) 604174.8 Ops/sec
querySelectorAll(.id) 767683.1 Ops/sec
jQuery(#id) 475864.4 Ops/sec
jQuery(.id) 180233.8 Ops/sec
jQuery(tag#id) 129227.6 Ops/sec
jQuery(tag.id) 133138.0 Ops/sec
jQuery + getElementById 721915.2 Ops/sec
jQuery + getElementsByClassName 196732.5 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