Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.92 Safari/537.36
Chrome 69
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 2584093.5 Ops/sec
getElementsByClassName() 1751280.1 Ops/sec
getElementsByTagName() 2178743.0 Ops/sec
querySelector(#id) 1748690.8 Ops/sec
querySelector(.id) 2399040.5 Ops/sec
querySelectorAll(#id) 741826.3 Ops/sec
querySelectorAll(.id) 906503.4 Ops/sec
jQuery(#id) 915488.4 Ops/sec
jQuery(.id) 437001.6 Ops/sec
jQuery(tag#id) 263445.4 Ops/sec
jQuery(tag.id) 262976.1 Ops/sec
jQuery + getElementById 931336.2 Ops/sec
jQuery + getElementsByClassName 341153.4 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


;