The time is right for a DOM templating API
10 months ago
- #templating
- #web-development
- #DOM
- Proposal for adding a declarative templating API to the web platform.
- Current DOM API lacks ergonomic templating, a cornerstone of modern web frameworks.
- Benefits of declarative templating include superior ergonomics, security against XSS, better performance, easier static analysis, and efficient server-side rendering.
- The absence of a native templating API leads to longer app download times, insecure apps, and increased developer overhead.
- Frameworks and libraries face challenges in implementing templating due to trade-offs between features, performance, and code size.
- Now is an opportune time to introduce a templating API, given the maturity of frameworks and developer demand.
- Popular templating systems share similar syntax and semantics, making standardization feasible.
- Tagged template literals in JavaScript provide a viable path for implementing templating without new syntax.
- JSX is popular but lacks semantics, making it difficult to standardize; tagged template literals offer a more immediate solution.
- HTML-based templating is a larger undertaking but could follow after establishing a JavaScript-based API.
- Reactivity models like VDOM, template identity, and signals have been explored, with template identity and signals being a promising combination.
- A proposal for a native templating API would benefit vanilla developers, web components, and frameworks, serving as a stepping stone to more advanced features.
- The proposal requires collaboration and effort to specify, but promises significant value for the web platform.