Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36
Chrome 74
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 2604796.5 Ops/sec
getElementsByClassName() 1600642.1 Ops/sec
getElementsByTagName() 1938000.8 Ops/sec
querySelector(#id) 1620625.9 Ops/sec
querySelector(.id) 2132803.8 Ops/sec
querySelectorAll(#id) 706954.6 Ops/sec
querySelectorAll(.id) 921098.8 Ops/sec
jQuery(#id) 844889.4 Ops/sec
jQuery(.id) 410857.7 Ops/sec
jQuery(tag#id) 258476.9 Ops/sec
jQuery(tag.id) 272273.2 Ops/sec
jQuery + getElementById 990777.6 Ops/sec
jQuery + getElementsByClassName 381710.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