If you want the deep article have a look here: https://coding-graphefruit.blogspot.de/2016/10/performance-angularjs-javascript.html
So here's the list to gain more performance:
AngularJs
Config
- $httpProvider.useApplyAsync(true);
- $compileProvider.debugInfoEnabled(false);
- $compileProvider.cssClassDirectivesEnabled(false);
- $compileProvider.commentDirectivesEnabled(false);
Run
- $animate.enabled(false);
Initialize
- Enable strictDi
1 2 3 | angular.bootstrap(document, ['myApp'], { strictDi: true }); |
Coding
Section about what you shall care about while coding:
Avoid
All points can be written "where possible".
- $q.defer
- $timeout, $interval
- $http
- animation
- two-way-binding
- ng-repeat (normaly you will need it everywhere)
- Filter | orderBy -> Do it inside your controller
- Custom-Attribute-Directives -> Do it inside your controller
- ng-template (<script type="text/ng-template" id="/tpl.html"></script>)
- ng-show
- ng-class
Use
- requestAnimationFrame instead setTimeout if no timeout needed
- debounce on heavy called functions (like scrolling)
- bind-once
- Virtual-Scroll on big ng-repeats
- "use strict;"
- ng-if
- ng-style
Don't forget
- Unregister $interval
- Unregister watcher ($scope.$watch)
- Unregister listener ($scope.$on)
- Minimize watchers/listeners (bind-once)
- Cache Templates
- Minimize CSS/JavaScript and combine (Gulp e.g.)
- Disable console.log's
- Use latest libraries
- Cache-Data
- Dependency-Injection (for minimizing code)
Many of this performance / avoiding points you'll find in many other topics but it was hard for me to find realy one topic which is handling all in once, so I set up my own little blog for this problems.
0 Kommentare:
Kommentar veröffentlichen
Hinweis: Nur ein Mitglied dieses Blogs kann Kommentare posten.