Run details:
Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36
Chrome 69
Windows 8.1
Desktop
6 years ago
Test name Executions per second
getElementById() 914966.3 Ops/sec
getElementsByClassName() 616482.9 Ops/sec
getElementsByTagName() 712070.6 Ops/sec
querySelector(#id) 521203.9 Ops/sec
querySelector(.id) 781397.9 Ops/sec
querySelectorAll(#id) 210101.6 Ops/sec
querySelectorAll(.id) 284739.7 Ops/sec
jQuery(#id) 226248.6 Ops/sec
jQuery(.id) 89646.4 Ops/sec
jQuery(tag#id) 50857.9 Ops/sec
jQuery(tag.id) 51177.6 Ops/sec
jQuery + getElementById 301135.3 Ops/sec
jQuery + getElementsByClassName 93245.1 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