Angularjs / rendering Performance difference between embedding or using ng-include

I can use ng-include to enable partial inside angular views, or I can use partial parts of the server to do this on the server. I am thinking of using server-side partial parts instead of angular partials, and then ng-include (with a script tag), because I read somewhere that angular partial create new areas, and this can hurt performance in $ digest.

Is there any justification for this? What affects performance when using angular, includes

+8
angularjs angularjs-ng-include
source share
1 answer

ng-include will create a new area and register the clock (in the path expression used by ng-include ) in the area where ng-include . Although this requires some additional processing, these are still JavaScript objects based and, as such, very fast. The effect of the new watch plus the additional volume in most cases should be completely negligible.

The only real difference that I see is that ng-include will include / render your partial asynchronously, so you can see a little delay, especially when getting partial data over the network (but this can be mitigated by preloads as described here: https://stackoverflow.com/a/318512/

In short: in most cases, the effect of ng-include should be negligible if partial files are preloaded .

One last comment: "premature optimization is the root of all evil." Do not start tuning micr-performance until you determine the performance of your application and determine that ng-include is the bottleneck.

+9
source share

All Articles