webtides / element-js

Simple and lightweight base classes for web components with a beautiful API
MIT License
26 stars 3 forks source link

Custom Parts renderer #67

Closed eddyloewen closed 1 year ago

eddyloewen commented 2 years ago

Rough summary: This adds a custom renderer just like lit but with built-in SSR functionality (being that TemplateResults from html can simply be rendered as strings) without the need for any shims or adjacent libraries. With this new renderer we don't constantly parse the template from string all the time and therefore will be able to use better features inside template. Now we can use special attributes like ?, . and @. The new renderer is way faster than the current vanilla renderer. If all goes well this new renderer should also be a bit faster than lit.

What is left to do?

Checking Performance/Regression: I've been checking the performance of the new renderer with a few metrics that can be done via the examples folder.

Metric Old vanilla renderer new parts renderer (beginning) parts renderer (final)
Render 0ms 0ms 1ms
Create 1k 28ms 29ms 24ms
Update 1k 70ms 8ms 8ms
Append 1k 54ms 26ms 26ms
Update every 10th 54ms 3ms 4ms
Swap 48ms 2ms 3ms
Select 1 51ms 2ms 3ms
Delete 1 47ms 17ms 12ms
Clear 115ms 64ms 31ms
Create 10k 240ms 216ms 176ms
Clear 10k 2329ms 817ms 136ms