angular's $http
service is triggering a $digest
on every get
(if no $digest
is already running):
if (!$rootScope.$$phase) $rootScope.$apply();
Ia addition to fetching objects from our API, our app has many directives with templateUrl
- which are fetched by angular using $http
. This causes hundreds of $digest
loops on cold start.
Commenting out the above line, reduces the number of $digest
loops to about 3, and the app runs MUCH faster, with no bindings broken (at least due to $http
not triggering a $digest
).
Is there a way to disable $http triggering the $digest?
use $httpProvider.useApplyAsync(true);
on app config. then the templates directive loaded within 10ms will face the same digest. this will reduce the digest cycle call.
see here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With