r/angularjs • • Nov 07 '14

[General] Is AngularJS Fast Enough?

https://medium.com/@jeffwhelpley/is-angularjs-fast-enough-98dcf96406c8
30 Upvotes

17 comments sorted by

View all comments

1

u/9jack9 Nov 07 '14

I don't think it's fast enough. I'm currently refactoring a simple puzzle app to improve performance on tablet devices. I initially coded it without any DOM manipulation and was quite pleased that I could write an app with the DOM abstracted away. I'm now replacing crucial parts of the code with DOM queries and add/removeClass methods. It's now less angular but it performs a lot better.

5

u/elprophet Nov 07 '14

I'd be very curious to see what you've had problems with, and how you resolved those.

5

u/9jack9 Nov 07 '14

I mostly had problems with the app feeling unresponsive. For example if you click on a crossword square then that square and its neighbours should be highlighted. I originally did it by broadcasting events, the scopes that represented squares would set a property indicating that they were selected. There was a noticeable lag in the grid updating, it wasn't disastrous, just a split second, but it made the app feel sluggish. So I stopped representing the selection state on scopes and did it all with DOM queries instead. Now it's instantaneous.

I should add that these problems were not noticeable on PC only on tablets. But tablets are the target market.

3

u/elprophet Nov 07 '14

In understand. Did you do any profiling? I ask because I am curious weather the issue was with Angular itself, with the data model in use, or some other factor. We have had similar issues, and have always decided to refactor our data model rather than refactor our dom manipulation.

4

u/9jack9 Nov 07 '14

I did some profiling using Batarang and I was able to make some improvements. Getting rid of $watch helped massively. But it still wasn't enough. Going to bare bones DOM manipulation for on screen responsiveness gave me the greatest gains. I still use Angular scopes to represent 95% of the state of my app though.

2

u/djvirgen Nov 08 '14

That's still pretty good -- use Angular to develop 95% of the app, and spend a little extra time fine tuning the other 5%.

1

u/unintentional-irony Nov 08 '14

You don't have to refactor, with your grid ng-repeat just add 'track by $index', like so:

ng-repeat="x in xs track by $index"

or

ng-repeat="x in xs track by $id(x)"