To detect heaps, start with a baseline sense of how scripts are loaded and executed in a website and app. Use a page load tool and measure the current average load time is. Once with a baseline, take a look at development tools that examine memory management. These tools typically can take snapshots that reflect when memory leaks occurs as a script executes.
The results are shown as an annotated timeline in most tools, similar to the page load speed tests that are available. Examine performance under a continuous paint mode doing this highlights how elements are being rendered.
Consider adjustments such as local scopes of variable, event listeners, manage local cache. After making adjustments, measure again to see if there is an improvement in the page load. Use a console tool to closely examine a sequence and trigger an element within the DOM.