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

Perf Idea: Template Compilation Re-use #13915

Open
@dcherman

Description

@dcherman

Filing this for future consideration since this will be too big of a change to even think about considering it for 1.5.

One optimization that I've used with a lot of success in perf sensitive components is the re-use of the compiled template rather than letting the compile step re-compile the same template over and over again.

The basic idea is that once a template is compiled, you store that template under a cache that is keyed with the template string itself. As a result, you get to skip quite a lot of the work previously done in compile especially in directives that are composed together.

Generic Bag of Concerns:

  1. Unbounded memory growth potential? What happens when a template is a function that changes often enough such that we have many stale cache entries. Is this reasonable?
  2. Similar to the above, are there concerns with people replacing the content of an already loaded templateUrl?
  3. This would completely fall apart if a directive uses compile. This is the biggest consideration I've come up with so far; the compile function would modify the generated function for all future linking usage which is almost definitely not what you would want, however we can feature detect this by checking for the presence of a compile function and bailing out.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions