-
Notifications
You must be signed in to change notification settings - Fork 27.3k
WIP: perf(ngInclude): cache linkFns for each template #10432
Conversation
This is probably not the best way to do this but here is a working Proof of Concept. See http://www.bennadel.com/blog/2738-using-ngrepeat-with-nginclude-hurts-performance-in-angularjs.htm
CLAs look good, thanks! |
Actually this is not right... |
OK, that is a bit better. But still this caching could probably be done inside $requestTemplate or $templateCache. |
@@ -231,6 +233,9 @@ var ngIncludeDirective = ['$templateRequest', '$anchorScroll', '$animate', '$sce | |||
var newScope = scope.$new(); | |||
ctrl.template = response; | |||
|
|||
// Compile and cache the template | |||
ctrl.linkFn = ctrl.linkFns[src] = ctrl.linkFns[src] || $compile(jqLiteBuildFragment(ctrl.template, document).childNodes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a shame to have to compile this way...
@petebacondarwin I was expecting something like lgalfaso@fd70eab |
Mine was a PoC to see if it was feasible and what the performance implication was; not an proper implementation. Your commit is closer to a clean solution but effectively the same idea no? |
@petebacondarwin yes, it follows the same idea |
Pushing to the backlog for now. |
I don't think we should do this. It is easy enough to get the caching you need for real application by using a directive with a templateURL instead (IMO). |
This is probably not the best way to do this but here is a working Proof of Concept.
See http://www.bennadel.com/blog/2738-using-ngrepeat-with-nginclude-hurts-performance-in-angularjs.htm
Here is demo: http://plnkr.co/edit/Pf9DVKxNEAZQavcGm7Bu?p=preview