Back to Angular

Performance

adev/src/content/best-practices/performance/overview.md

22.0.0-next.106.9 KB
Original Source

Performance

Angular includes many optimizations out of the box, but as applications grow, you may need to fine-tune both how quickly your app loads and how responsive it feels during use. These guides cover the tools and techniques Angular provides to help you build fast applications.

Loading performance

Loading performance determines how quickly your application becomes visible and interactive. Slow loading directly impacts Core Web Vitals like Largest Contentful Paint (LCP) and Time to First Byte (TTFB).

TechniqueWhat it doesWhen to use it
Lazy-loaded routesDefers loading route components until navigation, reducing the initial bundle sizeApplications with multiple routes where not all are needed on initial load
Deferred loading with @deferSplits components into separate bundles that load on demandComponents not visible on initial render, heavy third-party libraries, below-the-fold content
Image optimizationPrioritizes LCP images, lazy loads others, generates responsive srcset attributesAny application that displays images
Server-side renderingRenders pages on the server for faster first paint and better SEO, with hydration to restore interactivity and incremental hydration to defer hydrating sections until neededContent-heavy applications, pages that need search engine indexing

Runtime performance

Runtime performance determines how responsive your application feels after it loads. Angular's change detection system keeps the DOM in sync with your data, and optimizing how and when it runs is the primary lever for improving runtime performance.

TechniqueWhat it doesWhen to use it
Zoneless change detectionRemoves ZoneJS overhead and triggers change detection only when signals or events indicate a changeNew applications (default in Angular v21+), or existing applications ready to migrate
Slow computationsIdentifies and optimizes expensive template expressions and lifecycle hooksProfiling reveals specific components causing slow change detection cycles
Skipping component subtreesUses OnPush change detection to skip unchanged component treesApplications that need finer control over change detection
Zone pollutionPrevents unnecessary change detection caused by third-party libraries or timersZone-based applications where profiling reveals excessive change detection cycles

Measuring performance

Identifying what to optimize is just as important as knowing how to optimize it. Angular integrates with browser developer tools to help you find bottlenecks.

ToolWhat it does
Chrome DevTools profilingRecords Angular-specific performance data alongside browser profiling, with color-coded flame charts that show component rendering, change detection cycles, and lifecycle hooks
Angular DevToolsA browser extension that provides a component tree inspector and a profiler for visualizing change detection cycles

What to optimize first

If you are unsure where to start, profile your application first using the Chrome DevTools Angular track to identify specific bottlenecks.

As a general starting point: