Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36
Chrome 68
Linux
Desktop
6 years ago
Test name Executions per second
getElementById() 2015697.4 Ops/sec
getElementsByClassName() 1263157.0 Ops/sec
getElementsByTagName() 1383080.2 Ops/sec
querySelector(#id) 1038639.8 Ops/sec
querySelector(.id) 1391619.8 Ops/sec
querySelectorAll(#id) 436015.2 Ops/sec
querySelectorAll(.id) 495522.0 Ops/sec
jQuery(#id) 552523.6 Ops/sec
jQuery(.id) 274641.4 Ops/sec
jQuery(tag#id) 167389.5 Ops/sec
jQuery(tag.id) 177270.4 Ops/sec
jQuery + getElementById 727529.0 Ops/sec
jQuery + getElementsByClassName 238290.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