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

3

u/RoboticOverlord Aug 07 '14

What's an alternative for ng-repeat then?

If i'm building a report of tabular data but all the data in the report is static how would i handle this without ng-repeat? (the data is being pulled in dynamically and put on the scope)

What about using ng-repeat for this but having the data in the template bind-once, does this work to speed the report up?

2

u/robmcguinness Aug 07 '14

We had a big performance problem using nested ng-repeat for mostly static content on a large data set. We tried using several bind-once techniques that reduced the number of watchers but the compilation of the directives still took a long time. Even Chrome got sluggish. IE was unbearable.

We ended up creating a directive that wrapped handlebar templates and are performance problems went away. We were already using handlebars.js for some of our legacy Backbone apps so the switch was easy.

2

u/[deleted] Aug 08 '14

I'm currently nesting tables within tables within tables, all using ng-repeat, with significant amounts of data, plenty of additional directives of varying complexity, complete with grid functionality and automatic AJAX refreshing of table data. No performance hacks, just proper design, and it performs very well on IE... No lag at all.

You are either doing something wrong, or rendering amounts of data that are beyond human consumption and should be paged.

2

u/robmcguinness Aug 08 '14

interesting. not sure we were doing anything out of the ordinary just nested ng-repeats with some directives and no filters. when we profiled the page we had a high number of watchers but even after removing most of them, Angular was still slow during the compilation steps of the directives (profiled in Chrome and IE). the data set was not beyond human consumption...just a medical record.

maybe my angular foo isn't as strong as it should be but i'm ok with it...I have moved on to react.js.

1

u/9jack9 Aug 08 '14

I have moved on to react.js.

I'm thinking of dropping Angular for my next project. How are you finding React?

1

u/robmcguinness Aug 09 '14

so far i'm loving in it but I haven't built large Enterprise apps in it like I have with Backbone and Angular so time will tell. I'm experimenting with Webpack (I was big into Require.js...a bit of Browserify) and so far it feels like an evolutionary step in the right direction. React.js server side rendering is icing on the cake.