Advertisement
Beginner Angular, Performance & Lazy Loading

How do you check your Angular app's actual bundle size and find opportunities to reduce it?

Short answer

You build your app for production and use a bundle analysis tool, like source-map-explorer, to visualize exactly which packages and files are taking up the most space, helping you spot unnecessarily large dependencies or code that could be lazy loaded instead of included upfront.

Save Angular mock interview
Advertisement
AModel answer
You build your app for production and use a bundle analysis tool, like source-map-explorer, to visualize exactly which packages and files are taking up the most space, helping you spot unnecessarily large dependencies or code that could be lazy loaded instead of included upfront.
ng build --configuration production
npx source-map-explorer dist/my-app/*.js
// opens a visual chart showing which packages take up the most space
Real-world example
A team discovers a large unused charting library was accidentally being included in their main bundle, using source-map-explorer to visualize the bundle after a production build, and removes it to significantly reduce load time.
Likely follow-ups
  • What is a reasonable initial bundle size target for a typical Angular app?
  • How would you set a bundle size budget that fails the build if exceeded?
Related topics