Investigate step by step to find whether the time goes to network, JavaScript or rendering. 1. Reproduce and measure - Use a production build (ng build); development mode adds extra checks and is slower. - Record the page load or interaction in the Chrome DevTools Performance panel to see long tasks, scripting time and layout or paint cost. 2. Check the network - In the Network tab: is the component waiting for slow API calls, many sequential calls (waterfalls), large payloads or a big lazy-loaded chunk? - Fixes: parallelise independent calls (forkJoin), cache results, paginate, reduce payload size, optimise the API itself, or show the shell immediately with skeleton loaders. 3. Profile Angular change detection - Angular DevTools' profiler shows which components were checked, how often, and how long each took. - Signs of trouble: change detection running on every mouse move or timer, or one cycle taking tens of milliseconds. - Fixes: OnPush change detection, signals, avoiding template method calls (use pure pipes or computed values), running frequent events outside the zone. 4. Check rendering cost - Large lists without track or virtual scrolling create thousands of DOM nodes. - Fixes: track in @for, CDK virtual scrolling, pagination, simpler templates. 5. Look for heavy JavaScript work - Large synchronous loops, sorting or filtering big arrays on every update, or expensive third-party libraries initialising on load. - Fixes: memoise derived data, move computation to a Web Worker or the server, @defer heavy widgets. 6. Check subscriptions and memory - Duplicate subscriptions triggering repeated requests, or leaks making the app slower over time. 7. Confirm and protect - Measure again after each change to prove the improvement, and add a performance budget or test so the regression does not return. Explain the process with an example: "The dashboard took 6 seconds; profiling showed four sequential API calls and a 5,000-row table. Parallel requests plus virtual scrolling brought it under 1.5 seconds."
Ravindra Wadile · · 0 likes