For the new Coldsweat UI I'm trying to render stuff on the server as much as possible with the usual Flask + JInja approach and update elements on demand via Javascript and “fetch” calls.
This is a very old-school technique but it works and it is very lightweight on the client side. To update the page DOM I’m experimenting with morphdom (https://github.com/patrick-steele-idem/morphdom) and it is pretty cool.
I’ve resisted to recode everything using a SPA-like architecture because: 1) there’s too much work to do and I would end up to not release anything for another year, which is a non-goal for me; 2) at this point it is not clear to me if the overall UX would be better.
Another approach to update UI elements on the client would use a LiveView-like approach. In the Python world there are various packages for Django and Flask that implement that and I hoped to use them somehow but this complicates deploy.
Since LiveView needs and extra channel (being Serve Side Events or WebSockets) to communicate with client you have to start a separate process aside the Flask app.
Server Side Events are nice and way simpler than WebSockets but they need to works on multi-process deploy solutions too and this require extra complexity on the server. In Videobox I can use them, since I control the environment and run it via Waitress which use a multi-threaded server but for Coldsweat this is a deal-breaker.
Trade-offs, as usual…
#DevDiary