paf31 / purescript-sdom

An experiment in replacing the virtual DOM and avoiding diffing
MIT License
161 stars 13 forks source link

Feasibility of 'Baking' HTML Server-Side With SDOM #21

Open Etherian opened 6 years ago

Etherian commented 6 years ago

By 'baking' I mean rendering and storing beforehand an asset that would otherwise be generated at run time.

That is, would it be feasible to, as part of the transpile/build step, render and store the static portions of the HTML produced by the SDOM in the HTML file and replace the corresponding rendering procedures in the code with bindings to the generated HTML?

Would doing so have any performance benefits?

The idea of 'baking' HTML from a VDOM has been on my mind since I first looked into Elm, but it seems particularly relevant to your SDOM library, since the SDOM clearly delineates the static and dynamic parts of the page.

paf31 commented 6 years ago

I think it's doable if you were to drop the array function, but at that point you're just left with normal HTML templates.

I don't think I'd want to explore it here, but the SDOM idea is simple enough that you could try it out separately.

One potential issue is that SDOM currently uses references to HTML nodes in order to update them, and the references are created when the nodes are created, so you'd have to figure that out if you were to create the nodes in another way.

You might also be interested in my purview project, since that allows for model changes to be sent by the server, regardless of the way in which the nodes were created.