Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
Chrome 67
Linux
Desktop
6 years ago
Test name Executions per second
getElementById() 3565965.2 Ops/sec
getElementsByClassName() 2345944.0 Ops/sec
getElementsByTagName() 2904472.8 Ops/sec
querySelector(#id) 2162019.0 Ops/sec
querySelector(.id) 2947312.0 Ops/sec
querySelectorAll(#id) 994291.6 Ops/sec
querySelectorAll(.id) 1188629.2 Ops/sec
jQuery(#id) 1296068.0 Ops/sec
jQuery(.id) 585122.8 Ops/sec
jQuery(tag#id) 337045.3 Ops/sec
jQuery(tag.id) 337472.5 Ops/sec
jQuery + getElementById 1402839.1 Ops/sec
jQuery + getElementsByClassName 486219.7 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