Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36
Chrome 62
Windows
Other
7 years ago
Test name Executions per second
getElementById() 1691816.0 Ops/sec
getElementsByClassName() 1327602.9 Ops/sec
getElementsByTagName() 1463384.2 Ops/sec
querySelector(#id) 1508304.4 Ops/sec
querySelector(.id) 440901.8 Ops/sec
querySelectorAll(#id) 778196.4 Ops/sec
querySelectorAll(.id) 80307.4 Ops/sec
jQuery(#id) 628849.9 Ops/sec
jQuery(.id) 312728.1 Ops/sec
jQuery(tag#id) 207369.8 Ops/sec
jQuery(tag.id) 52523.2 Ops/sec
jQuery + getElementById 789218.3 Ops/sec
jQuery + getElementsByClassName 231520.2 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