3 ms·
I was playing with the idea of using JS objects as a template engine: http://m1el.github.io/jsonht.htm http://m1el.github.io/jsonht.htm, and I'm pretty happy wi
by m1el 10y ago
I was playing with the idea of using JS objects as a template engine: http://m1el.github.io/jsonht.htm http://m1el.github.io/jsonht.htm, and I'm pretty happy with it.
I think DOM is pretty damn fast in modern browsers. `innerHTML` can be slower than creating elements from a JS object!
Here's the script I'm using for timing: https://gist.github.com/m1el/b28625b3b9261f0fab819e866133e49a https://gist.github.com/m1el/b28625b3b9261f0fab819e866133e49...
My results in Chrome are: dom: 2663.580ms, innerHTML: 10999.449ms
- jbe_ 10y agoMe too, kind of, except I'm mostly using functions to construct the templates. Haven't tested the performance yet, but it should be good.. https://github.com/jbe/zodiac https://github.com/jbe/zodiac
- coldtea 10y ago>I was playing with the idea of using JS objects as a template engine: http://m1el.github.io/jsonht.htm http://m1el.github.io/jsonht.htm, and I'm pretty happy with it. Isn't that the same as (among several other things) React's JSX?
- abritinthebay 10y agoIt's pretty much identical. I don't think people realize that all JSX is, is a way to elegantly write out something that transpiles down to a pure object representation of the DOM. JSX and React have a few quirks where React means it's not quite a pure object, but the React devs are working on removing those.
- deleted 10y ago[deleted]
- m1el 10y agoYes, it is. If you replace Array literals with `React.createElement`, you will (almost) get compiled JSX templates.