Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.108 Safari/537.36
Chrome 63
Mac OS X 10.12.6
Other
2025 years ago
Test name Executions per second
getElementById() 3682572.5 Ops/sec
getElementsByClassName() 2338254.0 Ops/sec
getElementsByTagName() 2876478.8 Ops/sec
querySelector(#id) 3109074.2 Ops/sec
querySelector(.id) 699499.8 Ops/sec
querySelectorAll(#id) 1153282.6 Ops/sec
querySelectorAll(.id) 91538.6 Ops/sec
jQuery(#id) 1206730.8 Ops/sec
jQuery(.id) 589329.4 Ops/sec
jQuery(tag#id) 404773.0 Ops/sec
jQuery(tag.id) 73582.5 Ops/sec
jQuery + getElementById 1459518.6 Ops/sec
jQuery + getElementsByClassName 412034.6 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