Fork me on GitHub
#clojurescript
<
2022-04-27
>
Simon07:04:29

I currently have a #reagent project with a landing page and an “app” page. The landing page only makes use of Reagent to create a simple modal. I want to pre-render the landing page for better SEO and pagespeed score. I currently use #reitit for client side routing. There is currently no backend. How would you recommend I go about this? I heard that #rum could be a possible way forward?

simongray07:04:35

I would switch to Rum. I have used reagent for ~3 years and quite liked it for its ease of use, but I prefer Rum now even it is a little more involved. Rum also uses Hiccup and is like 99% compatible with reagent’s Hiccup, so the actual lines of code that need to change shouldn’t be too numerous. My preferred cljc stack is Rum + Pedestal

p-himik07:04:25

Alternatively, if you won't change that modal too often and if it doesn't share a lot of code with the main app, you can just write it in plain HTML. That's what I do, albeit for much simpler "App is loading" things.

Simon08:04:24

And then you would also rewrite the simple modal into vanilla js?

p-himik08:04:49

And if you want to deliver your CLJS bundle right with that page (or the main module, if you use module splitting), then goog also has a decent amount of dialog-related functionality.

simongray09:04:50

dat Rum though…

😄 1
J09:04:41

Recently, I test the old way approch (to build an app) but with some modern libs. I use ornament and rum to style components and render them to the server (CSS in clj). I use htmx and when I need more interactivity, I use rum with SSR. I agree with @U4P4NREBY. rum is very cool to use.

💪 2
Chris McCormick23:04:36

@U024A5W9WBG you could use a simple #nbb script to render the landing page on the server side at build time. Here's an example from @U04V15CAJ: https://github.com/babashka/nbb/blob/main/examples/reagent-ssr/example.cljs

👍 2
😎 1
timothypratley00:04:35

I have a very low tech way of achieving the goal: I just open my page in development, find the "app" <div>, copy outer HTML, and paste it into my index.html <-- it's very quick and dirty but it allows me to whack an async on the ClojureScript load.... the HTML shows the DOM before the app loads, and you don't notice when it takes over unless I change the default page and forget to recopy it. Sorry if this is too manual, just giving an option here if there isn't a clear way to integrate it into your built tools.

👍 1
Drew Verlee04:04:39

How does a dialog help?

Simon10:04:59

Thanks @U06S1EJPL, that is in fact exactly how i do it now 😄

1
pinkfrog10:04:58

js->clj doesn’t allow to specify a keywordise function. Normally how do you bypass this?

pinkfrog10:04:41

I guess I shall directly perform a map over the dict.

tugh12:04:43

Yeah, it is impossible to pass an fn but it would be nice IMO.

sansarip14:04:48

If you don’t mind pulling in an extra dependency, then I think https://github.com/mfikes/cljs-bean may also do the trick for you. See here 👉 https://github.com/mfikes/cljs-bean/blob/master/doc/key-mapping.md

pinkfrog14:04:27

Sadly for the recursive version, i.e., ->clj, keywordFN cannot be specified.

💩 1
tony.kay19:04:35

Why do the Clojurescript JARs include precompiled class versions of data.json and tools.reader? This is causing me some nightmares in production in Datomic Cloud. I think it is the case that the compiler will use newer source files if it finds them on the classpath, but what if the source files are older, and the class files in Clojurescript are incompatible? Or worse, the dependencies are precompiled in the target environemtn and you end up with class files for the same thing on the classpath twice (which is what I think I’m hitting). In that case you get very unpredictable results depedning on classpath ORDER. Those two things are listed as dependencies already…it seems having compiled versions in the JAR is going to lead to these kinds of problems, so why deploy jars with them?

lilactown19:04:07

i think this was being talked about in #cljs-dev

tony.kay19:04:24

ah, yeah, probably a better place. Thanks 🙂