Performance: Component lifecycle overview
MEDIUM IMPACT
This concept affects how quickly components appear and respond during page load and user interaction.
ngOnInit() { scheduleAsyncTask(); useAngularBindingsForDOMUpdates(); }ngOnInit() { heavySyncTask(); updateDOMDirectly(); }| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Heavy synchronous work in ngOnInit | Multiple direct DOM manipulations | Triggers multiple reflows | High paint cost due to layout thrashing | [X] Bad |
| Asynchronous tasks with Angular bindings | Minimal DOM operations via bindings | Single reflow after async completion | Low paint cost | [OK] Good |