How do you analyse and reduce the bundle size?

Angular performance and SSR · Experienced

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