Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1 Safari/605.1.15
Safari 12
Mac OS X 10.14.4
Desktop
5 years ago
Test name Executions per second
getElementById() 3988472.8 Ops/sec
getElementsByClassName() 3307907.5 Ops/sec
getElementsByTagName() 3450512.0 Ops/sec
querySelector(#id) 2996554.5 Ops/sec
querySelector(.id) 3346330.5 Ops/sec
querySelectorAll(#id) 2126974.2 Ops/sec
querySelectorAll(.id) 2297388.8 Ops/sec
jQuery(#id) 2483243.0 Ops/sec
jQuery(.id) 1288369.5 Ops/sec
jQuery(tag#id) 969895.3 Ops/sec
jQuery(tag.id) 942666.0 Ops/sec
jQuery + getElementById 1913838.0 Ops/sec
jQuery + getElementsByClassName 1316337.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