Closed titoBouzout closed 1 year ago
I came with the template caching by trying to figure out how to make it lazy. Wasn't intentional, it just happened. I'm not sure if it is worthy, as each call to cloneNode
now means it will do map.has
, map.get
, and then cloneNode
, template duplication doesn't seem to happen as frequently. So it's been removed from this pull request.
I appreciate the PR and the testing. The plan is to incorporate these improvements assuming they do well in my testing but I've taken it a bit more radically including improvements to compilation and code reduction. Expect to see this in 0.36.x.
Thank you for inspiring this.
Good news is this doesn't appear to have any negative impact on simple DOM benchmarks. Like if you show a table with 1000 rows.. and instead you now have to create it one extra time at 1001 it isn't move the dial very much. So that's positive. But lets hope this improves startup and hydration metrics. I think for SSR this is way more interesting because it means that we may never instantiate the template.
From time to time, one questions if templates should be created when used, instead of at start-up. Currently, solid creates all the templates at startup, regardless if these are going to be used or not.
In my opinion, templates should be created when used.
Pros:
Cons:
Alternatives:
Please note that this change also includes caching, which means that any template that has the exact same shape will be reused and not regenerated.Real life testing: