Hacker News new | ask | show | jobs
by fabiospampinato 982 days ago
Interesting how they say that compiled templates are ~21% faster to update, I wonder why. In theory pretty much anything that they could be doing at compile time could just be done at runtime, since they are building on top of tagged template literals, which enable this, so I guess there were some optimizations missing for that in v2? I'd be interesting if anybody knows what was missing.
1 comments

I ran that benchmark and can let you know what's going on. The benchmark switches templates using conditionals.

So what is happening is:

1. On the first render, every template that is rendered gets prepared. And there is that 46% improvement. 2. On the second render, some code paths change and some new templates that haven't yet been rendered get rendered. This results in a smaller improvement.

Then over time, as different code paths are exercised, the improvements of compilation reduce as every template has been seen at least once.