Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36
Chrome 74
Linux
Desktop
5 years ago
Test name Executions per second
getElementById() 4185423.0 Ops/sec
getElementsByClassName() 2709396.5 Ops/sec
getElementsByTagName() 3179973.2 Ops/sec
querySelector(#id) 2306661.8 Ops/sec
querySelector(.id) 3255378.5 Ops/sec
querySelectorAll(#id) 826422.1 Ops/sec
querySelectorAll(.id) 1046411.7 Ops/sec
jQuery(#id) 1233015.0 Ops/sec
jQuery(.id) 612333.6 Ops/sec
jQuery(tag#id) 357011.2 Ops/sec
jQuery(tag.id) 380004.1 Ops/sec
jQuery + getElementById 1410077.4 Ops/sec
jQuery + getElementsByClassName 549814.5 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