Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36
Chrome 63
Linux
Other
2025 years ago
Test name Executions per second
getElementById() 2734430.8 Ops/sec
getElementsByClassName() 1740944.0 Ops/sec
getElementsByTagName() 2149739.8 Ops/sec
querySelector(#id) 2191247.8 Ops/sec
querySelector(.id) 507868.3 Ops/sec
querySelectorAll(#id) 840945.9 Ops/sec
querySelectorAll(.id) 68131.8 Ops/sec
jQuery(#id) 898618.1 Ops/sec
jQuery(.id) 472366.2 Ops/sec
jQuery(tag#id) 279407.7 Ops/sec
jQuery(tag.id) 53883.9 Ops/sec
jQuery + getElementById 1035487.8 Ops/sec
jQuery + getElementsByClassName 287393.3 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