Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) snap Chromium/74.0.3729.157 Chrome/74.0.3729.157 Safari/537.36
Chromium 74
Linux
Desktop
5 years ago
Test name Executions per second
getElementById() 1591005.9 Ops/sec
getElementsByClassName() 1119722.2 Ops/sec
getElementsByTagName() 1191443.1 Ops/sec
querySelector(#id) 758008.8 Ops/sec
querySelector(.id) 1309376.9 Ops/sec
querySelectorAll(#id) 332407.8 Ops/sec
querySelectorAll(.id) 451476.3 Ops/sec
jQuery(#id) 383673.9 Ops/sec
jQuery(.id) 187742.5 Ops/sec
jQuery(tag#id) 115070.2 Ops/sec
jQuery(tag.id) 113200.7 Ops/sec
jQuery + getElementById 584450.4 Ops/sec
jQuery + getElementsByClassName 196854.2 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