Angular performance talk

17
Supercharge AngularJS Performance Measurement and Tuning && Sebastian Fröstl Damien Klinnert

Transcript of Angular performance talk

Page 1: Angular performance talk

SuperchargeAngularJSPerformance

Measurement and Tuning

&& Sebastian Fröstl Damien Klinnert

Page 2: Angular performance talk

We <3angular.js

Page 3: Angular performance talk

Hello world!

world<h3>Hello {{name}}</h3>

<input ng-model="name">

Page 4: Angular performance talk
Page 5: Angular performance talk
Page 6: Angular performance talk

Behind the AngularJS magic

Page 7: Angular performance talk
Page 8: Angular performance talk
Page 9: Angular performance talk

One:

Address book

Demo | Demo fixed

Page 10: Angular performance talk

Avoid watching invisibleelements

limit number of watches, use ng-if instead of ng-show

Page 11: Angular performance talk

Two: Bakery

Demo | Demo fixed

Page 12: Angular performance talk

No complex watch statementsprecalculate and cache results, make watches simple and fast

Page 13: Angular performance talk

Three: Numbers

Demo | Demo fixed

Page 14: Angular performance talk

Ensure DOM updates are

batched

don't use ng-include in ng-repeat, prefill the template cache

Page 15: Angular performance talk

Workflow“Performance tuning – set expectations, measure, tune, and

repeat” – {1}

1. Have a problem (no premature optimizations)

2. Set time/ budget limits

3. Measure correctly

4. Find main bottle necks

5. Fix bottlenecks one by one

(constantly measure and evaluate new state)

Page 16: Angular performance talk

Wrap upAngularJS detects model changes by dirty checking.

Within the $digest cycle a previous stored value is

compared to the actual model value. Process is repeated

until models are stable

One: Don't watch for invisible (ng-if > ng-show)

Two: Avoid complex watch-expressions

Three: Ensure DOM updtes are batched

Workflow: detect problem, set expectations, measure, fix,

repeat

* Small Improvements is hiring

Page 17: Angular performance talk

References1. Mastering Web Application Development with

AngularJS, Pawel Kozlowski, Peter Bacon Darwin,Packt Publishing, 23. August 2013

2. 3. 4. 5. 6. 7.

AngularJS Performance Tuning for Long ListsOptimizing AngularJS: 1200ms to 35msAnalysing Performance of AngularJS ScreensMisco Hevery on AngularJS performanceAngularJS: 6 Common Pitfalls Using ScopesBindonce: Zero watches binding for AngularJS