Server side rendering
eldoy opened this issue · 3 comments
How do I do server side rendering?
@eldoy great question! didn't really think about it as just using in the browser is so fast. However i'm sure an implementation can be done. The rendering algorithm is like 20LOC. Thoughts? Examples?
@snuggs There is no need for this library (or any other library really) when you can just use JS functions that returns template strings:
function link({ url, text }) {
return `<my-link><a href="${url}">${text}</a></my-link>`
}
This works both on server and browser (isomorphic even) with 0 (zero) dependencies. Is it worth spending time on creating something that is inferior to what is already working perfectly just for some syntactic sugar?
Interesting...probably just need some sort of "node parser". Under the hood we use the sparsely documented TreeWalker. What is an advantage is whatever other libraries are using to SSR can guarantee it is orders of magnitude more complex. We just use TreeWalker
. Wonder if there is anything lighter than JSDOM. Or whatever others are doing. Custom Elements ARE bonified DOM elements. Just thinking out loud.