Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/66.0.3359.181 Chrome/66.0.3359.181 Safari/537.36
Chromium 66
Ubuntu
Desktop
6 years ago
Test name Executions per second
getElementById() 3842818.8 Ops/sec
getElementsByClassName() 2461953.5 Ops/sec
getElementsByTagName() 2968037.5 Ops/sec
querySelector(#id) 2283443.0 Ops/sec
querySelector(.id) 3077633.8 Ops/sec
querySelectorAll(#id) 1017832.1 Ops/sec
querySelectorAll(.id) 1254880.5 Ops/sec
jQuery(#id) 1316999.0 Ops/sec
jQuery(.id) 650947.8 Ops/sec
jQuery(tag#id) 361632.9 Ops/sec
jQuery(tag.id) 379943.1 Ops/sec
jQuery + getElementById 1433824.8 Ops/sec
jQuery + getElementsByClassName 481584.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