Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Templates are currently half a solution to web component HTML #994

Open
mangelozzi opened this issue Mar 24, 2023 · 2 comments
Open

Templates are currently half a solution to web component HTML #994

mangelozzi opened this issue Mar 24, 2023 · 2 comments

Comments

@mangelozzi
Copy link

For me there is a constant tension between using templates because:

  • They are fast

And not using templates because:

  • They are slow in context because they require the same code to be inserted into the webpage every time, and re-downloaded.

Javascript and Styling can be externalised, so it can be downloaded once (often cached in memory for while the user is browsing the site).

Not so with the HTML of templates, one has to insert all the HTML templates from all the web components used from your web components into the DOM. There used to be external HTML templates but it was deprecated, with no alternative given.

One can put the HTML in a Javascript string where one declares your component JS, which is what I see most examples on the web doing, but this means one is not using the power of templates, and you don't have HTML linting in your text editor because you are working with JS files.

@sashafirsov
Copy link

@mangelozzi I guess you referring to the current state of templates which is far from the origin of template meaning in programming word:

  • template has to be reusable, hence cache-able
  • template does not need to be re-instantiated. It is not injected into DOM, rater reused during render.

The image which is part of icon font is the perfect sample of such template from reusability and rendering prospective. Unfortunately it is "passive" solution without parameters and does not have much of HTML qualities.

This has been raised almost without any traction on WICG discourse:

@sashafirsov
Copy link

Functionally complete declarative templating WICG proposal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants