Moh K
Moh K

Reputation: 514

Concurrent watches in AngularJS app

Currently, I am developing an AngularJS Application and get stuck at the finishing .

In order to improve the performance of my application and reduce memory consumption, I am thinking to limit the number of watch on a page.

Is there a recommended limit in AngularJS app for concurrent watch to have the best performance of the application?

Upvotes: 0

Views: 419

Answers (1)

Moh K
Moh K

Reputation: 514

To reduce memory consumption and improve performance it is a good idea to limit the number of watches on a page to 2,000. A utility called ng-stats can help track your watch count and digest cycles.

Jank happens when your application cannot keep up with the screen refresh rate. To achieve 60 frames-per-second, you only have about 16 milliseconds for your code to execute. It is crucial that the scope digest cycles are as short as possible for your application to be responsive and smooth. Memory use and digest cycle performance are directly affected by the number of active watches. Therefore, it is best to keep the number of watches below 2,000. The open-source utility ng-stats gives developers insight into the number of watches Angular is managing, as well as the frequency and duration of digest cycles over time.

Caution: Be wary of relying on a “single magic metric” as the golden rule to follow. You must take the context of your application into account.

The number of watches is simply a basic health signal. If you have many thousands of watches, or worse, if you see that number continue to grow as you interact with your page. Those are strong indications that you should look under the hood and review your code.

Here are my Sources:

https://github.com/kentcdodds/ng-stats

http://jankfree.org


Upvotes: 2

Related Questions