How do you analyse and reduce the bundle size?
Model answer
Build for production and look at the size report. Use a bundle analyser (for example source-map-explorer or the esbuild stats file) to see what takes space. Common wins: lazy load routes, import only what you use (specific lodash functions, not the whole library), replace heavy libraries with lighter ones, remove unused code, and use @defer for large widgets.
Set budgets in angular.json so the build warns or fails when bundles grow. Check again after each large dependency is added.
Learn this topic
Angular Tutorial: Beginner to Advanced .
Sign in to add your own answer.
More questions
- Why is track important in @for (or trackBy in *ngFor)?
- What are the main ways to improve Angular app performance?
- Why is calling a method in a template expression a performance problem?
- What is NgOptimizedImage and what does it give you?
- What is server-side rendering (SSR), and why would you use it?
- What is hydration in Angular?