Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36
Chrome 63
Windows 7
Other
2025 years ago
Test name Executions per second
getElementById() 2700573.8 Ops/sec
getElementsByClassName() 1435133.4 Ops/sec
getElementsByTagName() 1919235.0 Ops/sec
querySelector(#id) 2243630.0 Ops/sec
querySelector(.id) 479872.2 Ops/sec
querySelectorAll(#id) 885762.6 Ops/sec
querySelectorAll(.id) 67039.2 Ops/sec
jQuery(#id) 996933.6 Ops/sec
jQuery(.id) 480664.7 Ops/sec
jQuery(tag#id) 351229.4 Ops/sec
jQuery(tag.id) 55651.8 Ops/sec
jQuery + getElementById 969975.4 Ops/sec
jQuery + getElementsByClassName 330708.8 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


;