Created
April 22, 2016 19:06
-
-
Save Narayon/5f2cbb34594665abf3c81cc56eb7eed4 to your computer and use it in GitHub Desktop.
AngularJS 1.x Performance Tips
This file contains 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
In general, keep the digest cycle slim, avoiding the creation of watchers, when possible. | |
Some tips: | |
- ng-bind instead of {{expressions}} | |
- use bind once: ng-bind="::expression" or {{::expression}} | |
- avoid ng-repeat, but if necessary, use track by ... | |
- use small directives, with new or nested scope, instead of a monolithic scope | |
- use local events and $digest/$apply(when needed), to prevent running the digest cycle globally, for every event | |
- use $digest instead of $apply, when changes only affect children | |
- don't use filters in the DOM, use pre filtered data instead | |
- don't use true/false DOM logic in the controller | |
- avoid Angular directives, use vanilla | |
- is faster to generate new DOM elements, then manipulating existing ones |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment