Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.4 Safari/605.1.15
Safari 13
Mac OS X 10.13.6
Desktop
5 years ago
Test name Executions per second
getElementById() 2804648.8 Ops/sec
getElementsByClassName() 2095364.9 Ops/sec
getElementsByTagName() 2465798.2 Ops/sec
querySelector(#id) 1728953.4 Ops/sec
querySelector(.id) 1934827.5 Ops/sec
querySelectorAll(#id) 1374831.1 Ops/sec
querySelectorAll(.id) 1450588.8 Ops/sec
jQuery(#id) 1484093.9 Ops/sec
jQuery(.id) 601764.4 Ops/sec
jQuery(tag#id) 504052.1 Ops/sec
jQuery(tag.id) 501868.0 Ops/sec
jQuery + getElementById 1388401.5 Ops/sec
jQuery + getElementsByClassName 764006.1 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