Skip to content

Instantly share code, notes, and snippets.

@donbrae
Last active July 17, 2022 12:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donbrae/0276d43b831af40d1bbe529549a66f84 to your computer and use it in GitHub Desktop.
Save donbrae/0276d43b831af40d1bbe529549a66f84 to your computer and use it in GitHub Desktop.
`getElementById` vs `querySelector` vs `getElementsByClassName` vs `getElementsByName` vs `getElementsByTagName`.
https://measurethat.net/Benchmarks/ShowResult/170533
Test name | Executions per second
-----------------------------------------------
getElementById | 9,737,553 ops/sec
getElementsByName | 6,090,861 ops/sec
querySelector | 5,577,396 ops/sec
getElementsByTagName | 4,900,635 ops/sec
getElementsByClassName | 4,736,003 ops/sec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment