I was contemplating a means to increase performance in an app while meeting client demands. Right now it seems that the digest runs 5x per second where we only really need it to run perhaps twice per second.
Is there a way to lower the amount of times the digest runs?
In AngularJS there are a set of scenarios when a digest cycle kicks in, some of them are, whenever a value bind to the $Scope or $rootScope object changes(like
$scope.textor$rootScope.text), DOM Events (like ng-click, ng-bind etc..), Ajax with callbacks ($http etc..), Timers with callbacks ($timeout, setTimeout etc..), calling $apply, $digest etc..PFA:
To do:
If you want to reduce the number of digest cycles triggered you'll have to look into each of these above-listed points. Like you can reduce the number of
$watchersby using one-time binding (eg: {{::myProperty}} - documentation), limiting the cases of programmatically triggering $apply ($scope.$apply), and replacing$timeoutswith$scope.$evalAsync()(because$scope.$evalAsync()will try to trigger in the same digest loop itself whereas$timeout()will wait for the current digest cycle to be done) or un registering the watchers once you found the change and no longer required to watch again like this,etc..