Smaller Angular Bundles

by Stephen Fluin

2017-01-20

Smaller Angular Bundles
Building smaller Angular bundles is a big deal. Performance matters to your users, and the speed of your application is heavily based on your bundle size.
Here are the top tips for making smaller bundles:
  • Don't import MaterialModule, instead pull in any components that you need directly such as MdButtonModule or MdInputModule.
  • Don't import all of rxjs, instead import Observables such as import { Observable} from 'rxjs/Observable'; and then add any of the operators you need manually import 'rxjs/add/operator/map';
  • Lazy load every route in your application
  • Use AOT

Doing this, my hope is that your application's critical path bundles should be 100kb or less when gzipped.