Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Angular Performance 101
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Aviv Ben-Yosef
June 17, 2014
Programming
18k
1
Share
Angular Performance 101
From JS-IL 2014, given on June 17, 2014.
Aviv Ben-Yosef
June 17, 2014
More Decks by Aviv Ben-Yosef
See All by Aviv Ben-Yosef
HTTP API Design: UX for the Nitpickeriest
avivby
0
57
Stuff You Didn't Know You Can Do with RSpec
avivby
1
3.2k
Introduction to Rubinius
avivby
1
4k
DRY Introduction
avivby
1
290
How BillGuard Does MongoDB
avivby
5
3.2k
Other Decks in Programming
See All in Programming
CSC307 Lecture 17
javiergs
PRO
0
240
RailsTokyo 2026#4: AI様があれば、 Hotwireの弱点は消えるか?
naofumi
5
990
LLM Plugin for Node-REDの利用方法と開発について
404background
0
120
AI時代だからこそ「Bloc」を採用する価値があるのかもしれない
takuroabe
0
240
Agentic UI beyond Chats Architecture Patterns & Open Standards @ngMunich 05/2026
manfredsteyer
PRO
0
150
不変条件と整合性境界—ビジネスが決める設計判断と実現パターン / Invariants and Consistency Boundaries
nrslib
9
2.6k
Moments When Things Go Wrong
aurimas
3
120
AI時代の仕事技芸論 — ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ
kuranuki
0
190
Are We Really Coding 10× Faster with AI?
kohzas
0
240
JavaDoc 再入門
nagise
0
130
ユニットテストの先へ:テスト技法で要求・仕様を整理するJava開発実践 / Beyond_Unit_Testing_Practical_Java_Development_Techniques_for_Organizing_Requirements_and_Specifications
shimashima35
0
240
Signal Forms: Beyond the Basics @ngBaguette 2026 in Paris
manfredsteyer
PRO
0
120
Featured
See All Featured
A Soul's Torment
seathinner
6
2.8k
BBQ
matthewcrist
89
10k
The agentic SEO stack - context over prompts
schlessera
0
790
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
430
Site-Speed That Sticks
csswizardry
13
1.2k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
350
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
250
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
200
Being A Developer After 40
akosma
91
590k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.9k
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.7k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Transcript
Angular Performance 101
Disclaimer
“Premature optimization is the root of all Evil”
A story
None
<div ng-repeat=“task in tasks”> <span> {{ task.title }} </span> <span>
{{ task.date | fromNow }} </span> </div>
Why did it keep updating?
None
$interval(function() { $http.get(‘/events’) .success(function(events) { if (events) { $scope.events =
events; } }); }, 20 * 1000);
Why?
Angular == SO. MUCH. MAGIC.
“With great power comes great responsibility”
We’ll learn How dirty checking is performed When it runs
What you should do
The Secret
Magic == Dirty checking
How dirty checking is performed
Digest Loop
Digest == Run all watch expressions
$scope.$watch()
… and {{ stuff }}
… and ng-show=“foo()”
… and isolated scope variables scope: {foo: ‘=’}
… and {{ value | myFilter }}
… and ng-repeat itself
Watch Expressions $scope.$watch() {{ stuff }} ng-show=“list.length > 0” isolated
scope bindings: {foo: ‘=’} filters: {{ date | fromNow }} ng-repeat Basically everything
When does it run?
User actions
ng-click
ng-change
ng-model
… and $http responses
… and when $q promises are resolved
… and when using $timeout or $interval
… and whenever you call $scope.$apply() or $scope.$digest()
When digest runs User actions (ng-click, ng-model, etc.) $http responses
$q promises resolved $timeout / $interval $scope.$apply() / $scope.$digest() Basically: a lot of things
So? Who cares?
None
But when the shit hits the fan
You click and the screen freezes for a while The
only* performance issue that is angular’s fault
Are all clicks slow? Or just a certain screen?
One Screen is Slow That screen has bad scopes: Too
many watches Watch handlers that take too long
Everything is Slow Your digest loop is taking too long
You’re doing it wrong
Pinpoint it
Batarang
See watch expression
See slow expressions
Time Your $digest console.time(‘digest’); $rootScope.$digest(); console.timeEnd(‘digest’); http://jsfiddle.net/mbRf8/
What you should do
Make watches faster
Making Watches Faster Switch deep watch with $watchCollection $scope.$watch(‘myList’, function()
{}, true); ! $scope.$watchCollection(‘myList’, function() {});
Making Watches Faster Deep watch a subset $scope.$watch(‘myList’, function() {},
true); ! $scope.$watch( function() {return _.pluck($scope.myList, ‘id’);}, function() {}, true);
Making Watches Faster Make the change handler more performant
Have less watches
ng-repeat is your enemy
ng-repeat is your enemy Use track by <div ng-repeat=“task in
tasks track by task.id”> http://bit.ly/1kyvet7
ng-repeat is your enemy Paginate <div ng-repeat=“task in tasks”> !
<div ng-repeat=“task in tasksPage”>
ng-repeat is your enemy Row Virtualization à-la ng-grid http://angular-ui.github.io/ng-grid/
ng-repeat is your enemy Bind Once https://github.com/Pasvaz/bindonce <div bindonce ng-repeat=“task
in tasks”> ! <span bo-text=“task.title”></span> ! </div>
Have Less Watches ng-hide & ng-show elements are still there,
consider using ng-if Consider replacing filters with pre-calculated values
Badass AKA “I’m Desperate”
Badass Mode Write an angular-less widget
Your Mission Pinpoint bad watches Make watches faster Use less
watches
Thank You! Aviv Ben-Yosef @avivby www.deflect.io ! My angular &
web development newsletter www.codelord.net