Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393
Chrome 51
Windows
Other
8 years ago
Test name Executions per second
getElementById() 3395291.2 Ops/sec
getElementsByClassName() 1714507.4 Ops/sec
getElementsByTagName() 1982269.9 Ops/sec
querySelector(#id) 1099940.4 Ops/sec
querySelector(.id) 198644.7 Ops/sec
querySelectorAll(#id) 725738.8 Ops/sec
querySelectorAll(.id) 591911.4 Ops/sec
jQuery(#id) 502427.9 Ops/sec
jQuery(.id) 236137.5 Ops/sec
jQuery(tag#id) 33120.4 Ops/sec
jQuery(tag.id) 28627.0 Ops/sec
jQuery + getElementById 565559.9 Ops/sec
jQuery + getElementsByClassName 212381.0 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


;