Fork me on GitHub
#reitit
<
2020-06-30
>
magnus.kvalevag11:06:11

Hi! 🙂 What is best-practice for reusing routes in the browser? Compiling our routes now takes ~1500-2000ms, which is fine on the server, but they are also compiled on the client because we are using the same cljc namespace. Our naive approach so far has been to have a single cljc file routes.cljc which we require both on the server and on the client. It’s made the dev experience very nice, but has over time become too slow because the routes are compiled in Clojurescript every time we run it in the browser.

magnus.kvalevag12:06:11

The only solution I can think of is to somehow do all of the route-handling on the server and don’t depend on the routes on the client. I found a way to do this (without changing the calling sites) using a macro that stores all needed url-template-strings for a namespace and passes them on to the client in a map, but it feels hacky 🙂

magnus.kvalevag20:06:11

Hey, thanks a lot 🙂 Looking into the linear router I also realized that we hadn’t upgraded to the latest version for a while, d’oh! Upgrading to 0.5.2 from 0.3.1 (which is over a year old) yielded the biggest increase in performance, down to 550ms, and using the linear router got it down to 250ms.