Skip to content

Instantly share code, notes, and snippets.

@jonmaim
Created August 12, 2014 16:15
Show Gist options
  • Save jonmaim/fe19a8077de115a8e1e6 to your computer and use it in GitHub Desktop.
Save jonmaim/fe19a8077de115a8e1e6 to your computer and use it in GitHub Desktop.
Get number of Angular watchers in the page
(function () {
var root = angular.element(document.getElementsByTagName('body'));
var watchers = 0;
var f = function (element) {
if (element.data().hasOwnProperty('$scope')) {
watchers += (element.data().$scope.$$watchers || []).length;
}
angular.forEach(element.children(), function (childElement) {
f(angular.element(childElement));
});
};
f(root);
return watchers;
})();
@jonmaim
Copy link
Author

jonmaim commented Aug 12, 2014

Paste this in the console!
More info: http://stackoverflow.com/a/23470578

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment