Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

WIP: perf(ngInclude): cache linkFns for each template #10432

Closed

Conversation

petebacondarwin
Copy link
Contributor

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

@googlebot
Copy link

CLAs look good, thanks!

@petebacondarwin
Copy link
Contributor Author

Actually this is not right...

@petebacondarwin
Copy link
Contributor Author

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);
Copy link
Contributor Author

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...

@lgalfaso
Copy link
Contributor

@petebacondarwin I was expecting something like lgalfaso@fd70eab

@petebacondarwin
Copy link
Contributor Author

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?

@lgalfaso
Copy link
Contributor

@petebacondarwin yes, it follows the same idea

@petebacondarwin petebacondarwin modified the milestones: Backlog, 1.3.x - superluminal-nudge Sep 7, 2015
@petebacondarwin
Copy link
Contributor Author

Pushing to the backlog for now.

@petebacondarwin
Copy link
Contributor Author

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).

@petebacondarwin petebacondarwin deleted the ng-include-perf branch November 24, 2016 09:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants