I can use ng-include to include a partial inside an angular view or I can use server side partials to do it on the server. I'm thinking about using server side partials instead of angular partials and then ng-include (with the script tag) because I read somewhere that angular partials create new scopes and this can hurt performance on $digest.
Is there any validity to this. What is the effect on performance when using angular includes
ng-include
will create a new scope and register a watch (on a path expression used byng-include
) on a scope where theng-include
is used. While this incurs some additional processing it is still JavaScript-objects based and as such is very fast. The effect of a new watch plus an additional scope should be totally negligible in most cases.The only real difference I can see is that
ng-include
will include / render your partial asynchronously, so you might see a bit of delay, especially when fetching partials over the network (but this can be mitigated by pre-loading partials as described here: https://stackoverflow.com/a/12346901/1418796)In short: in most cases the effect of
ng-include
should be negligible if partials are pre-loaded.One last comment: "premature optimization is the root of all evil". Don't start micr-performance adjustments until you measure performance of your application and determine that
ng-include
is a bottleneck.