Last active
August 29, 2015 14:08
-
-
Save iamjohnlong/63e1253a4457df86cf19 to your computer and use it in GitHub Desktop.
Angular bind count taken from http://larseidnes.com/2014/11/05/angularjs-the-bad-parts/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Paste in console. | |
function getScopes(root) { | |
var scopes = []; | |
function traverse(scope) { | |
scopes.push(scope); | |
if (scope.$$nextSibling) | |
traverse(scope.$$nextSibling); | |
if (scope.$$childHead) | |
traverse(scope.$$childHead); | |
} | |
traverse(root); | |
return scopes; | |
} | |
var rootScope = angular.element(document.querySelectorAll("[ng-app]")).scope(); | |
var scopes = getScopes(rootScope); | |
var watcherLists = scopes.map(function(s) { return s.$$watchers; }); | |
_.uniq(_.flatten(watcherLists)).length; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment