Hey, my team is looking into Kobweb. I saw that Ko...
# kobweb
s
Hey, my team is looking into Kobweb. I saw that Kobweb is has silk, which seems to be applying styles through JS. I was looking to see if maybe it exported a css file, so that it could be optimized, or even just split up into different chunks. This doesn't seem to be the case. Is there anything I should be worried about here in terms of performance, or application bloat?
d
Performance? Not that I've seen. Application bloat? Possibly a concern! Although I'd worry more about the generated JS size from the rest of your code far far more than the CSS.
Note that what Kobweb is doing is really Compose HTML's approach (with respect to creating styles in the code)
You can do a static export if you want to see roughly how large the CSS styles are, and use that for an estimate of how much that will affect your final JS output size.
It's an interesting question that I haven't thought much about (since I believe lots of other frameworks import large stylesheets without really thinking about it), but I'll try to remember to keep an eye on it!
Feel free to file a feature request to allow exporting css styles into a file / generally optimize styles like removing things you don't use, or I'll do it later today. That said, it will be at least a few months before I can even look into it.
s
is it generating a css class per usage?
d
There's a global StyleSheet value (lives in Silk) which gets appended to
s
so for each usage a new class is created?
d
A new class?
s
css class
I assume not
d
Every new widget that gets added to Silk will add an entry to the StyleSheet
s
I see
that makes sense
d
At the moment, I'm planning on including a core set of useful widgets that many people will want. Later, as widgets get more exotic, they can be added to non-core libraries, so people might only import them if they want
OK, rough estimate incoming...
Copy code
$ kobweb create app/empty
... accept all default answers ...
$ cd empty/site
$ kobweb export --layout static
The empty app template is basically a minimal skeleton that just imports dependencies and has a stubbed root index page. When you do a static layout export, Kobweb takes a snapshot of each page in your app, which we can use to see how large the style section is. So, I opened
empty/site/.kobweb/site/index.html
inside IJ and highlighted the <style> sections, and it says that that's 10721 characters. So, roughly 1 byte per character, you can estimate that 11K of the download size is probably attributed to styles. The full JS output for the empty site, after dead code elimination? 417K. So 2-3% of your JS output is styles.
I can see that size going up to maybe 15K, or even let's go crazy and say 20K, when Silk's core widget set is "finished"
Also, as you develop, the size of your site will almost certainly increase far faster than the block taken up by styles.
s
yeah
I'm a bit nervous about that
our website is very large
I'm thinking that maybe we'll need to split it up
so that the js payload isn't so large
d
I do have the seed of a plan to allow splitting up Kobweb sites into multiple subdomains
s
maybe each feature will be treated as a separate build target on web
d
If you're willing to generate pages dynamically, you can also look into dynamic routes, where one page handler can handle a wide range of URL values.
s
I have a feeling that with compose web, getting a 10+MB page is pretty easy
d
(Compose Web, which is WASM? Or Compose HTML?)
s
compose html. sorry
d
No worries, it's confusing
s
I imagine the same is true on compose web
d
I think you'd have to work pretty hard to get to 10+ MB
but it is worth understanding with Compose HTML approaches that you can't really just download parts of a site
You get the whole darn thing
s
yeah, I get that
d
So when you visit https://bitspittle.dev, you are downloading all blog posts even if you never read any of them
(which I'll definitely want to fix at some point, right now it's OK because I only have 4 posts)
s
We've recently done a bunch of research into next.js, astro, vite. We are taking a step back in terms of deployment tech with compose-html. I get that. But we get the ability to target multiplatform... That's the goal here
d
Text is cheap. The whole site + JS is easily eclipsed by a hi-res header photo.
Yeah, I can appreciate the hesitancy.
s
A slightly worse experience on each platform, but a more cohesive experience as a whole, with a much cheaper dev cost.
It's less about the JS download size. It's more that the JS has to be interpreted and JITed. That makes things slow when you have several MB. I'm guessing here. I'm not a JS expert.
d
Fair enough. I haven't seen anything to be worried about yet, and lighthouse performance reports seem to be fine so far. But not sure what happens to larger projects.
More like the performance issues I've seen are when you try to do too many fancy animating effects on the screen
s
i imagine css animations would still do very well
d
Yeah, they're fine
I mean more like, if you do multiple layers with transparency effects
Not Kobweb/Compose HTML issues, but pure issues with forcing the CSS engine to do crazy things
s
sure