Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.42 Safari/537.36
Chrome 68
Linux
Desktop
6 years ago
Test name Executions per second
getElementById() 2127254.8 Ops/sec
getElementsByClassName() 1502542.4 Ops/sec
getElementsByTagName() 1752346.5 Ops/sec
querySelector(#id) 1226736.4 Ops/sec
querySelector(.id) 1659814.5 Ops/sec
querySelectorAll(#id) 456131.2 Ops/sec
querySelectorAll(.id) 611540.7 Ops/sec
jQuery(#id) 546206.7 Ops/sec
jQuery(.id) 192117.5 Ops/sec
jQuery(tag#id) 122216.3 Ops/sec
jQuery(tag.id) 111289.4 Ops/sec
jQuery + getElementById 775428.1 Ops/sec
jQuery + getElementsByClassName 202248.9 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