How to detect unnecessary renderings of DOM elements in your web app to improve performance

The code examples I'm giving is using Angular but it's only a very low amount of code to illustrate...