Closed Th3Whit3Wolf closed 3 weeks ago
Could you clarify for me — Is the application code here different from hackernews_islands_axum
, or just serving precompressed assets? If it's the same application, I'd love to have this as a PR to the existing islands example, rather than two separate examples.
(I'd also suggest adding a few comments explaining the changes: for example, the predicate filtering etc.)
The only real difference is that it serves the precompressed assets, dynamically compresses the HTML before serving it, and embeds the precompressed assets. It also returns a 404 instead of 500 when a request is made for an asset that doesn't exist.
I made another PR in case you'd prefer an update to the current hackernews_islands_axum
example
One of the things I love about leptos is how easy it is to ship a small frontend.
Leptos provides islands that reduce the amount of total HTML generated and it's build tool minifies CSS with
lightningcss
, soon will be minifying javascript withswc
, and it can even precompress these static assets. That last of which I think may be the most important because web assembly compress fairly well and it allows the user to ship their entire app as 1 static binary (with musl).Since precompression was added as a feature in
cargo-leptos
I haven't seen it mentioned a whole lot so I wanted to help people see how to use it. I have also seen a couple question about setting up compression in general so I added that too.In this example all static assets are compressed with
cargo-leptos
and the HTML is dynamically compressed.The type of compression sent will depend on what the client supports.
The resulting network usage
NOTE: My local cargo-leptos is built with PR 285 so the javascript is a bit smaller than what the current will produces.
EDIT: Reran and fixed numbers in table