Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/68.0.3440.75 Chrome/68.0.3440.75 Safari/537.36
Chromium 68
Ubuntu
Desktop
6 years ago
Test name Executions per second
getElementById() 2716539.5 Ops/sec
getElementsByClassName() 1736281.5 Ops/sec
getElementsByTagName() 1951233.0 Ops/sec
querySelector(#id) 1393783.6 Ops/sec
querySelector(.id) 1925078.9 Ops/sec
querySelectorAll(#id) 591436.2 Ops/sec
querySelectorAll(.id) 693101.4 Ops/sec
jQuery(#id) 611798.5 Ops/sec
jQuery(.id) 242835.6 Ops/sec
jQuery(tag#id) 148182.8 Ops/sec
jQuery(tag.id) 149844.3 Ops/sec
jQuery + getElementById 917868.3 Ops/sec
jQuery + getElementsByClassName 263820.9 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