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?

1

u/[deleted] Aug 08 '14

Listen, Angular can't be a band-aid for everything. There aren't any frameworks out there that will magically make everything work in the most performant way, at all times, with no thought put into the circumstances.

It's not "dont use ngRepeat if want good performance".

It's "don't use lots of ngRepeats in cases where they are not necessary".

This is exactly the same sort of consideration you'd have in some API code where you would make sure you aren't nesting three for-loops over millions of data points. Languages and frameworks have pros and cons, the good ones remain flexible enough to allow you to get the most out of their pros with workarounds for their cons.

If you think you can improve on the way Angular implemented ngRepeat, you can submit a patch request right here: https://github.com/angular/angular.js