Web Components with static and dynamic content

RE:DOM is the perfect tool for creating HTML components

Juha Lindstedt
RE:DOM
Published in
2 min readNov 10, 2017

--

Google’s Polymer team have lately talked about this new way to create templates, lit-html, which is heavily copied from HyperHTML.

Tagged template literals provide a way to update components smarter, so that static content is untouched and only the dynamic part gets updated. There’s a lot of performance and memory benefits of doing that, compared to virtual dom approach, where you need to diff everything.

RE:DOM have always supported this by design. Instead of defining a single create/update method, you define constructor and update methods separately:

Let’s use this component:

Result:

Fiddle with this example

The benefit of RE:DOM is that you can use pure JavaScript without learning and hassling with complicated templating languages. Browser support is also way better: IE 6 vs latest evergreen (or with lots of polyfills).

RE:DOM is one of the fastest view libraries there is, faster than almost any virtual dom library – including React. Memory usage is also very low, thanks to the class support and the way RE:DOM uses the DOM.

Give RE:DOM a try: https://redom.js.org
Questions? https://gitter.im/redom/redom

Happy JavaScripting! 😎

--

--

Juha Lindstedt
RE:DOM
Editor for

Web architect at iDiD digital signage, creator of RE:DOM