Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ngEurope: High-Performance Applications with Angular

ngEurope: High-Performance Applications with Angular

Slides from my session at ngEurope 2018 in Paris

Manfred Steyer

February 05, 2018
Tweet

More Decks by Manfred Steyer

Other Decks in Programming

Transcript

  1. ManfredSteyer About me… • Manfred Steyer • SOFTWAREarchitekt.at • Angular

    Trainings and Consultancy • Google Developer Expert (GDE) Page ▪ 3 Manfred Steyer
  2. ManfredSteyer Contents • Lazy Loading • Performance for Data Binding

    with OnPush • AOT and Tree Shaking • New and upcoming features • [Caching with Service Worker: Subsequent Sessions]
  3. ManfredSteyer Module Structure Page ▪ 10 AppModule … … …

    SharedModule Root Module Feature Modules Shared Module
  4. ManfredSteyer Lazy Loading Page ▪ 11 AppModule … … …

    SharedModule Root Module Feature Modules Shared Module
  5. ManfredSteyer Root Module with Lazy Loading Page ▪ 12 const

    APP_ROUTE_CONFIG: Routes = [ { path: 'home', component: HomeComponent }, { path: 'flights', loadChildren: './[…]flight-booking.module#FlightBookingModule' } ];
  6. ManfredSteyer Routes for "lazy" Module Page ▪ 13 const FLIGHT_ROUTES

    = [ { path: '', component: FlightBookingComponent, […] }, […] }
  7. ManfredSteyer OnPush flights flight flight {{ flight.id }} {{ flight.id

    }} FlightSearch Card Card Angular just checks when “notified”
  8. ManfredSteyer "Notify" about change? • Change bound data (@Input) •

    OnPush: Angular just compares the object reference! • e. g. oldFlight === newFlight • Raise Event within the component • Notify a bound observable • observable$ | async • Trigger it manually • Don't do this at home ;-) • At least: Try to avoid this
  9. ManfredSteyer Advantages of AOT • Better Startup-Performance • Smaller Bundles:

    You don't need to include the compiler! • Tools can easier analyse the code • Remove unneeded parts of frameworks • Tree Shaking
  10. ManfredSteyer Angular CLI • ng build --prod • @ngtools/webpack with

    AngularCompilerPlugin • Can be used without CLI too
  11. ManfredSteyer Solutions Angular Language Service • Plugins for IDEs AOT

    for debugging • Possible since Angular 5 • Incremental AOT • Fast after 1st recompilation • ng serve --aot • Give it a try!
  12. ManfredSteyer Further improvements in upcoming versions New AOT Compiler: More

    treeshakable Code No Breaking Changes "Early numbers are extremely promising in terms of code size" • -- Rob Wormald, Angular Developer Advocate • https://goo.gl/KTFMqd
  13. ManfredSteyer More about this in my Medium Account • Configuration

    Details, Samples, Videos etc. • https://medium.com/@ManfredSteyer/angular-performance-tuning- article-series-6e3c33707b25
  14. ManfredSteyer Quick wins Use the CLI Try out AOT for

    debugging New Version: Better Performance