This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-05-08
Channels
- # announcements (14)
- # babashka (16)
- # beginners (15)
- # biff (15)
- # calva (48)
- # clj-kondo (42)
- # cljdoc (25)
- # clojure (18)
- # clojure-europe (75)
- # clojure-nl (1)
- # clojure-norway (19)
- # clojure-romania (1)
- # clojure-uk (10)
- # conjure (18)
- # core-typed (4)
- # cursive (16)
- # emacs (8)
- # fulcro (27)
- # graalvm (17)
- # honeysql (14)
- # hyperfiddle (9)
- # lsp (24)
- # missionary (5)
- # music (1)
- # nrepl (20)
- # off-topic (14)
- # re-frame (9)
- # reagent (34)
- # reitit (2)
- # releases (1)
- # shadow-cljs (19)
- # sql (16)
- # squint (9)
- # testing (2)
- # tools-build (10)
I have about twenty or so static files on the server the contents of which eventually end up in my app-db. I am curious whether it's a reasonable approach to build up my initial app state on the server, serialize it, and then send it over the wire alongside my bundled JS? Or should I prefer making ad-hoc fetch requests to grab the bits and pieces as I need them? I'm currently using this latter approach but it feels a little overcomplicated for what is a more-or-less simple application.
Depends largely on the size of the data and, I guess, on the connection quality of your users.
Most of them are fairly small, but I guess if I were to make a big initial request of the ensemble, it wouldn't be that much different in practice than simply having them all in the bundle to begin with, and then the bundle size is an issue. Well, as long as there are no other obvious concerns, it's something to think about.
"Fairly small" is not an objective metric. :) For me, it's up to 1 MB. For others, it can be 100 kB or 100 MB.
Thanks for the frame of reference. That's helpful. They're each smaller than 100kb for sure.
IMHO data should stay data and not become part of a .js
file. you can however put the data directly into the HTML in some way, so that no extra request is required.
As far as I'm aware, where you put it doesn't make any practical difference, at least not for the overall UX. However, putting a lot of data right into HTML can make things worse for the server if the website ends up being crawled frequently.
I'd fire a single dispatch to fetch all of it in a bundle when the app starts. On the back-end, have an endpoint that will call all the necessary functions or simply assemble the expected payload in the correct format and send it all at once. That way you get fast initial appearance in your app, the data transfers in the background and is set into app-db when it arrives. Makes the app seem more "progressive", as Google likes to call those style apps.