Mamun
Mamun

Reputation: 68933

What is the total numbers of $watch an AngularJS application can have?

What is the total numbers of $watch an AngularJS can have? Is there any performance issue of the application depends on this numbers?

Upvotes: 0

Views: 315

Answers (2)

Rakesh Chand
Rakesh Chand

Reputation: 3113

A large number of AngularJS watchers are usually the source of slowdowns in angular build applications.

When using $scope.$watch(...) angular will create a new watcher to check for changes on each $digest cycle and be able to notify the controller or update the view.

It is generally accepted that once the number of watchers reaches 2000+, an application will start to suffer.

Upvotes: 2

Mistalis
Mistalis

Reputation: 18279

It can not be said that there is a "limit" on the number of watchers on a page.

However, watchers do have a cost in terms of performance. You should avoid creating them when this can be avoided: reducing the number of watchers will directly improve the digest cycle’s performance.


I invit you to read this very interesting paper about AngularJS performance and watchers.

Upvotes: 1

Related Questions