Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0
Firefox 58
Windows
Other
2025 years ago
Test name Executions per second
getElementById() 3142241.0 Ops/sec
getElementsByClassName() 2517047.5 Ops/sec
getElementsByTagName() 3080029.8 Ops/sec
querySelector(#id) 2403971.5 Ops/sec
querySelector(.id) 374855.3 Ops/sec
querySelectorAll(#id) 1160315.2 Ops/sec
querySelectorAll(.id) 42577.1 Ops/sec
jQuery(#id) 2938887.2 Ops/sec
jQuery(.id) 843370.2 Ops/sec
jQuery(tag#id) 513165.1 Ops/sec
jQuery(tag.id) 42748.4 Ops/sec
jQuery + getElementById 2559163.2 Ops/sec
jQuery + getElementsByClassName 551159.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