Run details:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0
Firefox 61
Ubuntu
Desktop
5 years ago
Test name Executions per second
getElementById() 1574291.9 Ops/sec
getElementsByClassName() 1541710.5 Ops/sec
getElementsByTagName() 1881785.6 Ops/sec
querySelector(#id) 1728665.6 Ops/sec
querySelector(.id) 1599609.5 Ops/sec
querySelectorAll(#id) 442023.1 Ops/sec
querySelectorAll(.id) 711949.2 Ops/sec
jQuery(#id) 1658018.0 Ops/sec
jQuery(.id) 504471.6 Ops/sec
jQuery(tag#id) 246365.1 Ops/sec
jQuery(tag.id) 237806.6 Ops/sec
jQuery + getElementById 1386758.0 Ops/sec
jQuery + getElementsByClassName 498190.4 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