<@U02AB5P2XU6> I would be interested to learn more...
# kobweb
s
@David Herman I would be interested to learn more about static deployment with Kobweb as I could be interested by leveraging a variation of that in Spring for server-side rendering. I have read https://bitspittle.dev/blog/2022/staticdeploy, and tried https://bitspittle.github.io/kobweb-ghp-demo/. What I would like to understand more is how you switch from the static to the dynamic version. Is there a mechanism to hydrate the server-side generated HTML with handlers, etc?
Could that be a way to optimize the footprint on client side?
d
I think I have a comment in the code where I call it poor man's hydration. When you pull down the site, it gets completely torn up and rebuilt first thing.
The static snapshot is good for three things: first, SEO in case there are crawlers that don't run JS. Second, I think it gives the user the appearance of a slightly quicker load (maybe). But third (and most importantly) is to fool static site hosting providers.
Let me know if that answers your questions!
The code for taking page snapshots is here: https://github.com/varabyte/kobweb/blob/a8910bf5168a3e27be88ab49fce8b0a86322caac/gradle-plugins/application/src/main/kotlin/com/varabyte/kobweb/gradle/application/tasks/KobwebExportTask.kt#L46 The trickiest part is digging through the dynamic styles and converting them to static ones.
s
Ah great, that link to the code taking snapshot will be useful for me, thanks for sharing.
d
Ah to answer your question about optimizing the client side, I don't think I currently can. What I'm doing is fairly blunt.
One thing I'd be interested in doing if it was possible is breaking the page script up into many pieces and users would download what they need dynamically.
This would make initial downloads smaller, and make it more likely that some script parts would get cached by the browser automatically.
If I could ever get that to work, I think the nice thing is future Kobweb users would get it for free. But I don't even know if it's technically possible.