Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36
Chrome 69
Mac OS X 10.13.5
Desktop
6 years ago
Test name Executions per second
getElementById() 3504706.5 Ops/sec
getElementsByClassName() 2198617.0 Ops/sec
getElementsByTagName() 2546390.8 Ops/sec
querySelector(#id) 1944218.6 Ops/sec
querySelector(.id) 2734810.0 Ops/sec
querySelectorAll(#id) 718725.6 Ops/sec
querySelectorAll(.id) 942917.4 Ops/sec
jQuery(#id) 899594.2 Ops/sec
jQuery(.id) 294651.5 Ops/sec
jQuery(tag#id) 175790.2 Ops/sec
jQuery(tag.id) 171096.2 Ops/sec
jQuery + getElementById 1121570.0 Ops/sec
jQuery + getElementsByClassName 271176.0 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