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 for loop vs closest (miss) vs for loop (miss)
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
for loop
closest (miss)
for loop (miss)
Fastest:N/A
Slowest:N/A
Latest run results:
Run details: (Test run date:
6 months ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36