closest vs querySelector performance for large dom (version: 1)
Goal: Get the target element inside the DOM
Test case #1 - You don't have the target id - Find a target element through DOM via Element.closest()
Test case #2 - You have the target id from your state - Find the target element via Document.querySelector()
Comparing performance of: closest vs querySelector
Memory measurements supported only in Chrome.
For precise memory measurements Chrome must be launched with --enable-precise-memory-info flag.
More information: Monitoring JavaScript Memory
Test case name
Result
closest
querySelector
Fastest:N/A
Slowest:N/A
Latest run results:
Run details: (Test run date:
11 days ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36 Edg/132.0.0.0