Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Utility to count watchers in an AngularJS app. The higher the number of watchers, the slower your app will run.
* Utility to count watchers in an AngularJS app.
function countWatchers() {
var root = angular.element(document.getElementsByTagName('body'));
var watchers = [];
var f = function (element) {
if ('$scope')) {
angular.forEach($scope.$$watchers, function(watcher) {
angular.forEach(element.children(), function(childElement) {
console.log('watchers.length: ', watchers.length);
(function() {
countWatchersTimeout = window.setTimeout(countWatchers, 10000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.