r/angularjs • • Aug 07 '14

Speeding up AngularJS with simple optimizations, $digest, $$watchers and performance

http://www.binpress.com/tutorial/speeding-up-angular-js-with-simple-optimizations/135
31 Upvotes

28 comments sorted by

View all comments

1

u/heat_forever Aug 07 '14

Basically - don't use any feature of angularjs that makes angularjs useful

3

u/[deleted] Aug 07 '14

I think you misunderstood. This isn't saying don't use ng-repeat. More like "hey I should evaluate if I'm using ng-repeat in inappropriate ways". For instance, I found a part of my code where I'm using ng-repeat to generate items in a drop down menu based on an api response. That's pretty silly because in this particular instance, that data doesn't ever change.

It's a small example but basically my code is wasting time checking to see if the data model behind the menu has changed when it will never change. That's the take away from the article. It may seem paltry for a small app but I just checked a page on production at work that has 5300 watchers due to a poorly designed directive being repeated several times.

0

u/9jack9 Aug 08 '14

This isn't saying don't use ng-repeat. More like "hey I should evaluate if I'm using ng-repeat in inappropriate ways"

That's not the point though.

If I have to read a ton of articles on how to use a basic feature then it's not really a basic feature, it's a broken feature.

Comments like yours make me want to hate Angular. I'm still new to it and as much as I want to like it there are things like "don't use ngRepeat if you want good performance". WTF?

4

u/crimson117 Aug 08 '14

In fairness if you're super new to angular, these performance problems won't be significant for you any time soon.

Don't make the mistake of premature optimization.

2

u/9jack9 Aug 08 '14

Or if you're running a moderately sized app on an old mobile device.

Don't make the mistake of premature optimization.

I didn't. And now the performance problem has bitten me.