Run details:
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36 OPR/42.0.2393.94
Opera 42
Windows
Other
7 years ago
Test name Executions per second
getElementById() 3331544.0 Ops/sec
getElementsByClassName() 2170338.0 Ops/sec
getElementsByTagName() 2612336.0 Ops/sec
querySelector(#id) 2727446.2 Ops/sec
querySelector(.id) 658855.2 Ops/sec
querySelectorAll(#id) 1248690.8 Ops/sec
querySelectorAll(.id) 117679.1 Ops/sec
jQuery(#id) 1107801.8 Ops/sec
jQuery(.id) 569954.9 Ops/sec
jQuery(tag#id) 413576.3 Ops/sec
jQuery(tag.id) 80872.2 Ops/sec
jQuery + getElementById 1281967.5 Ops/sec
jQuery + getElementsByClassName 416534.8 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