Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36
Chrome 55
Mac OS X 10.11.2
Other
7 years ago
Test name Executions per second
getElementById() 1813362.9 Ops/sec
getElementsByClassName() 1213981.8 Ops/sec
getElementsByTagName() 1431467.9 Ops/sec
querySelector(#id) 1417115.1 Ops/sec
querySelector(.id) 440780.8 Ops/sec
querySelectorAll(#id) 519721.0 Ops/sec
querySelectorAll(.id) 58593.8 Ops/sec
jQuery(#id) 392899.5 Ops/sec
jQuery(.id) 176336.1 Ops/sec
jQuery(tag#id) 119781.3 Ops/sec
jQuery(tag.id) 34525.9 Ops/sec
jQuery + getElementById 756443.8 Ops/sec
jQuery + getElementsByClassName 156343.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