Skip to content

Comment on AngularJS Performance in Large Applicationsparent

Comments

Also disagree with

  > 6.2 Watching Functions
  >
  > Another common problem is the utilization of functions
  > in watchers or bindings. Never bind anything (ng-show,
  > ng-repeat, etc.) directly to a function. Never watch
  > a function result directly. This function will run on
  > every digest cycle, possibly slowing your application
  > to a crawl. 
A while ago this sort of advice was true (when you'd see people inlining stuff in `eval` to avoid this), but nowadays function execution itself is very fast.

You don't want to watch a slow function, but just watching a function will not "[slow] your application to a crawl."

Interesting post, but I'd take this author's advice with some salt.

I disagree strongly as well. For example if you have something like ng-show="is_admin()" and $scope.is_admin = function() { return $scope.logged_in && $scope.role='admin' } or some other complexity reducing function, I don't understand how that would be significantly less performant than copying and pasting the return statement everywhere in your html.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.