r/Clojure • u/roman01la • Sep 13 '17
PWAs built in ClojureScript?
Been reading through yet another case study about migrating a website to Progressive Web App architecture in JS (https://medium.com/dev-channel/treebo-a-react-and-preact-progressive-web-app-performance-case-study-5e4f450d5299) and it got me thinking are there any known PWAs in production built in ClojureScript?
Also, is there anything that cljs might lack in order to be able to ship a PWA? We already have code splitting and server side rendering.
17
Upvotes
1
u/eccp Sep 14 '17
So far I only could find https://github.com/gja/pwa-clojure which also links to this deck: https://speakerdeck.com/gja/progressive-web-apps-in-clojure-script
1
2
u/dustingetz Sep 14 '17 edited Sep 14 '17
Hyperfiddle is a progressive web app, all possible states can be SSRed
The hard part is that React.js rendering takes significant compute, its fine when each user does their own rendering, but when hosting renders for the world paying 200ms per user per dynamic page is not a great place to be and single-threaded Nodejs does not make this easy, there's no easy way yet to chunk up this 200ms of work to make it nonblocking, you need a nodejs cluster. React Fiber should help in theory but details are unclear. There is a lot of future work to be done to make React.js PWAs work out, its not as simple as just SSR it once and stick a CDN in front of it like a blog.
Hyperfiddle does not solve this yet, I am collecting links about this here if anyone would like to contribute: https://www.reddit.com/r/reactssr/
Oh and did I say 200ms per dynamic page? Its more like 10 seconds for some pages. I do believe we can get that down to milleseconds, but it requires being extremely careful with how you code your React components; fast performance is possible but is nowhere close to free and tiny little things can blow the whole page perf. The final answer is probably going to involve saving the virtual dom in server session and using reactive forceUpdate on the server, just like how the browser gets fast perf. So that means sticky sessions and React.js monkey patches.