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:
16 days ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36