Angular Performance Tips

We had our final OC|CS Demo Night last night at the Sony Gaikai Offices (really really cool place!), and I had the awesome opportunity to talk to a bunch of recruiters and developers.

One of the things I really appreciated from last night’s Demo Night was that several developers who attended asked to look at my code. Rob, who is a Sr. Product Engineer at Mossio, gave me some great feedback on my code structure and tips on using Node environment variables to protect sensitive keys for privacy.

I also got to chat with Isaac, who is a Developer at Sony Gaikai. He pointed me to look up some resources about Angular performance precautions with using $scope.$watch and also suggested I look up Bind Once :: to also improve performance.

Isaac explained to me that I should be careful in using $scope.$watch because I can potentially run into performance issues on larger Angular applications.

The eager developer that I am =p, I did more reading and I found this primer on Angular performance: 11 Tips To Improve AngularJS Performance.

Essentially, Angular performance issues usually arise when there are too many watchers in the app (or inefficient uses of watchers), since Angular uses dirty checking on the digest cycle to keep track of all the changes in app. (Aka, Angular goes through every watcher to check if they need to be updated).

Likewise, using Bind Once :: can be helpful for values that aren’t going to be updated. The example that Isaac gave was the name/username of a person’s account. By using Bind Once, Angular binds the value once, but then doesn’t check to see if the value is updated in the future – thereby reducing the amount of watchers in the digest loop.

This is my third? week using Angular so it’s great to be able to get some tips from more experienced developers. Thank you to everyone who has supported me through this bootcamp!

Duncan Leung

Front End Developer at iHerb.com

Irvine, CA

Subscribe to Duncan Leung: Javascript and Front End Development

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!