JohnPaulHarold / crt

Apache License 2.0
1 stars 0 forks source link

Investigate server side rendering #17

Open JohnPaulHarold opened 1 year ago

JohnPaulHarold commented 1 year ago

A common pain point with performance on TVs and STBs is creating and managing DOM with lots of JavaScript. Some of this DOM construction is unavoidable and makeElement() helps with that, but some could be avoided and skipped if the server just gave us the HTML already.

If this sounds familiar, then I guess it's how websites used to work, before single page apps became a thing and servers were reduced to being dumb data stores. The key difference is, we want to avoid reloading everything else, like a regular web app with different routes, and instead add and remove large-ish fragments of HTML and carry on scripting against those.

Yes, still sounds familiar.

JohnPaulHarold commented 1 year ago

See https://github.com/JohnPaulHarold/crt/tree/crt17/ssr

JohnPaulHarold commented 1 year ago

Further investigations done, and this above branch now has a server that will render some DOM and the script required. The rendered page isn't much more than a hello world with the simplest of scripts, but it shows that you can pass in the template and add the behaviours from the server.