Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36
Chrome 61
Linux
Other
7 years ago
Test name Executions per second
getElementById() 3243906.2 Ops/sec
getElementsByClassName() 2172346.0 Ops/sec
getElementsByTagName() 2669841.2 Ops/sec
querySelector(#id) 2771463.5 Ops/sec
querySelector(.id) 694175.0 Ops/sec
querySelectorAll(#id) 1078745.6 Ops/sec
querySelectorAll(.id) 90634.6 Ops/sec
jQuery(#id) 1286008.6 Ops/sec
jQuery(.id) 651301.5 Ops/sec
jQuery(tag#id) 386372.4 Ops/sec
jQuery(tag.id) 67460.6 Ops/sec
jQuery + getElementById 1385203.8 Ops/sec
jQuery + getElementsByClassName 396616.5 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