developit / htm

Hyperscript Tagged Markup: JSX alternative using standard tagged templates, with compiler support.
Apache License 2.0
8.67k stars 170 forks source link

Question: Why not always return an Array? #204

Closed timonson closed 3 years ago

timonson commented 3 years ago

Hi guys, I really like your htm function and the performance of it! But the undetermined return type causes a lot of complications especially with regards to the usage of nested function calls.

There is probably a good reason why you chose this return type and I would love to know it. Otherwise I would consider it to be bad design and I would suggest changing it.

Would you also be so kind and clarify for me which one of these two alternatives is exported in the CDN version: export default MINI ? build : regular; ?

Thanks!

developit commented 3 years ago

Always returning an array is expensive for implementors because it creates an implicit fragment that has its own diff overhead. Design niceties aren't a metric worth optimizing for if they aren't free.

Both versions are hosted on unpkg, the default is the full version. Mini is at https://unpkg.com/browse/htm@3.0.4/mini/

timonson commented 3 years ago

Thanks!