Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36
Chrome 66
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 2321691.5 Ops/sec
getElementsByClassName() 1663608.4 Ops/sec
getElementsByTagName() 2124994.2 Ops/sec
querySelector(#id) 1669522.5 Ops/sec
querySelector(.id) 2210448.8 Ops/sec
querySelectorAll(#id) 786307.9 Ops/sec
querySelectorAll(.id) 934516.6 Ops/sec
jQuery(#id) 1055000.9 Ops/sec
jQuery(.id) 456054.4 Ops/sec
jQuery(tag#id) 258017.2 Ops/sec
jQuery(tag.id) 253220.5 Ops/sec
jQuery + getElementById 1122849.1 Ops/sec
jQuery + getElementsByClassName 310858.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