Wonderful developers, I need a little help clarifying why Angular 2 is more performant than Angular 1?
After searching the web, I came up with this relevant explanation from Er Shahbaz Sharif in a Quora discussion:
Angular 2 is using Hierarchical Dependency Injection system which is major performance booster.
Angular 2 implements unidirectional tree based change detection which again increases performance .
As per ng-conf meetup, angular 2 is 5 times faster as compared to angular 1
Other explanations in the same discussion seem to hover around this as well.
Could somebody please clarify for me why those 2 factors (and others, if any) help boost the performance of Angular 2? Thanks so much..
Angular2 - doesn't do deep object compairson. If items are added/removed to/from an array, change detection won't detect it. The same for object properties as long as they are not directly bound from the view.
Two-way binding is split into propagating detected changes from root to leaves only.
Changes from child to parent are only propagated by explicit events (outputs), only to direct parents.
ChangeDetectionStrategy.OnPush doesn't run change detection for components when no input values have changes. This prunes subtrees of components where change detection isn't run at all.
The code (especially the change detection code) is written in a way that it can be optimized as much as possible by the JS VMs.
https://www.quora.com/What-is-the-difference-between-angularjs-and-angular2
One of the reasons for performance is the possibility of the existence of change detection loops.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With