Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36 OPR/56.0.3051.104
Opera 56
Windows 7
Desktop
6 years ago
Test name Executions per second
getElementById() 2671223.8 Ops/sec
getElementsByClassName() 1600267.2 Ops/sec
getElementsByTagName() 2252213.2 Ops/sec
querySelector(#id) 1657937.4 Ops/sec
querySelector(.id) 2236008.0 Ops/sec
querySelectorAll(#id) 615966.8 Ops/sec
querySelectorAll(.id) 756214.3 Ops/sec
jQuery(#id) 960937.9 Ops/sec
jQuery(.id) 474462.6 Ops/sec
jQuery(tag#id) 273204.1 Ops/sec
jQuery(tag.id) 279363.2 Ops/sec
jQuery + getElementById 1087937.9 Ops/sec
jQuery + getElementsByClassName 412201.3 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