Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
Chrome 67
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 2261001.0 Ops/sec
getElementsByClassName() 1383354.4 Ops/sec
getElementsByTagName() 1716887.6 Ops/sec
querySelector(#id) 1243108.6 Ops/sec
querySelector(.id) 1740998.5 Ops/sec
querySelectorAll(#id) 621532.6 Ops/sec
querySelectorAll(.id) 750451.8 Ops/sec
jQuery(#id) 806266.9 Ops/sec
jQuery(.id) 363060.7 Ops/sec
jQuery(tag#id) 222485.9 Ops/sec
jQuery(tag.id) 236973.2 Ops/sec
jQuery + getElementById 824678.9 Ops/sec
jQuery + getElementsByClassName 324543.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