Re: [w3c/webcomponents] [templates] Ensure that template instantiation actually improves the platform (#704)

Hi @dmitriid 

I don't follow why template instantiation could only be used inside a web component.  It would be useful anytime there's repetitive markup that needs customizing in each instance.  I encounter that scenario quite a bit, before and after web components.

The fundamental issue templates are trying to solve, as I understand it, is that repeatedly cloning a template for large chunks of easy to parse html is faster than making lots of appendChild or innerHTML calls, which can only be done after the expensive job of parsing the JavaScript.  This is an empirical claim.  Are you claiming otherwise?   It would be great to show your counter-factual results.  

HTML templates also feel much more "declarative" to me.  Templates are inert, containing a data format (xml-ish) so they can be loaded quickly with no side effects.  hyperscript may also have no side effects for simple examples (other than rendering the html of course), but you can evaluate [any function you want](https://github.com/hyperhype/hyperscript#children---array) during the processing, which could have unexpected side effects.  To be fair, some aspects of the template instantiation proposal (which looks quite different from how you are describing it, with your before and after -- are we looking at the same proposal?) may also [allow for functions](https://github.com/w3c/webcomponents/blob/gh-pages/proposals/Template-Instantiation.md#32-template-parts-and-custom-template-process-callback) with side effects, but I could be wrong.

For the record, I'm not opposed to introducing an h function into the api, if it fulfills some useful purpose, but I fail to see how it is easier to use than tagged template literals.  Could you elaborate?  The performance numbers I've seen comparing lit-html and hyperHTML, compared to react (and even preact) make me wonder what your objections are?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/704#issuecomment-475195086

Received on Thursday, 21 March 2019 11:32:06 UTC