Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36
Chrome 70
Windows 7
Desktop
6 years ago
Test name Executions per second
getElementById() 2385206.8 Ops/sec
getElementsByClassName() 1512787.9 Ops/sec
getElementsByTagName() 1905415.8 Ops/sec
querySelector(#id) 1471282.4 Ops/sec
querySelector(.id) 1906821.9 Ops/sec
querySelectorAll(#id) 590112.1 Ops/sec
querySelectorAll(.id) 745189.9 Ops/sec
jQuery(#id) 906789.6 Ops/sec
jQuery(.id) 425625.5 Ops/sec
jQuery(tag#id) 243042.7 Ops/sec
jQuery(tag.id) 258185.5 Ops/sec
jQuery + getElementById 901907.8 Ops/sec
jQuery + getElementsByClassName 289802.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