Skip to content

Instantly share code, notes, and snippets.

@mattymess
Created October 7, 2014 21:54
Show Gist options
  • Save mattymess/61251df59986a8a6f8bc to your computer and use it in GitHub Desktop.
Save mattymess/61251df59986a8a6f8bc to your computer and use it in GitHub Desktop.
Determine number of angular watchers
(function() {
var root = $(document.getElementsByTagName('body'));
var watchers = [];
var f = function(element) {
if (element.data().hasOwnProperty('$scope')) {
angular.forEach(element.data().$scope.$$watchers, function(watcher) {
watchers.push(watcher);
});
}
angular.forEach(element.children(), function(childElement) {
f($(childElement));
});
};
f(root);
console.log(watchers.length);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment