Fork me on GitHub

i was just experimenting with a quickstart clojurescript project, adding just an str (clojure.core) function to the code created 96K compiled JS file.. did any one here tried to cut down the clojurescript runtime part after compiling or is there already a way for that?


96K is tiny after gzipping - so there's really nothing more to do

👍 4

solved the size issue using google closure library, instead of using clojure str/other core functions used the google closure counter part, now the size is 1 KB (566B gzipped) my intention was creating a small loading script before loading my re-frame app (loaded via iframe) starting to love clojurescript & the ecosytem of tools ❤️


How do you deploy a gzipped js? Asking as a complete newbie... so please be patient


Normally gzip option is set in the server (like Nginx) and Server streams compressed content to browser and then browser will decompress it


@renlinx you will experience a sunk cost in order to support all of the Clojure machinery, but it doesn’t grow linearly from there, no need to worry that much about it.

👍 4
Elias Elfarri11:08:56

Hello i am trying to get a distance from the client to a div because i want to track the x,y coordinates of the mouse inside said div. So i am trying to use that to find an offset to clientX and clientY. I've been trying different values to get offsets but with no luck yet. (fn [event] (-> event .-target .-getBoundingClientReact .-left)) and (fn [event] (-> event .-target .-getBoundingClientReact .-top)) has not worked. I am a bit of a novice in cljs, so would love to get some feedback on what i am doing wrong

Elias Elfarri11:08:17

This code is by the way written on a :onClick inside the div element


getBoundingClientReact - replace "React" with "Rect" • .- is used to get a field, but you need to call a function there - remove -

Elias Elfarri11:08:31

i think i just misspelled it here, but i still have the same issue. When i try to console log it, i get back a "lambda [event]". I am expecting to get an integer?


Sounds like you're logging the (fn [event] ...) and not its result.


Works just fine for me:

> (-> js/document (.querySelector "div") .getBoundingClientRect .-height)


You could get the bounding box coordinates of the div like this


  {:ref (fn [e] (when-not (nil? e)
                 (let [rect (.getBoundingClientRect e)
                                  left (.-left rect)
                                  right (.-right rect)
                                  top (.-top rect)
                                  bottom (.-bottom rect)
;; do something useful here


That won't work in the described desired scenario: "track the x,y coordinates of the mouse inside said div".


Once the bounding box coordinates are there you could calculate the offset using clientX and clientY (unless I am not understanding the issue). You could store the bounding box details in an atom, then use the onClick event to get the clientX and clientY coordinates and map them onto the bounding box?


We don't know if the node can change its size without being re-mounted.


Getting the bounding client rect of a (.-target event) should be no worse than your approach, even if it happens on every mouse move.

Elias Elfarri13:08:08

Yeah it seemed like i was console logging as you mentioned @U2FRKM4TW. Works as intended now. Thanks for the help guys!

Elias Elfarri13:08:34

i put the console-log inside the fn instead


any recommendations on what library to use for graphs/data visualization with cljs?


I haven't tried it yet though


I don't think it's meant to work in the browser


Why? It states in its README that it has components for Reagent.


And you can always use Vega without any wrappers via interop. I do just that, and it works just fine.


I'll try using Vega


I usually use D3 via interop and start by copying some snippets I created at


niiiiiiice... 😃

👍 3

I starting to lean more towards D3 now


oz uses vega uses d3

👍 3
Nom Nom Mousse06:08:56

Cool! I did not know vega used d3

Christopher Gsell16:08:45

Has anyone had any issues with the Google Closure compiler and the tick.alpha.api library? I am simply invoking this function: (tick/format (tick/date-time)), and it works fine in the dev environment, but does not work in the optimized build. I'm familiar with objects and declaring externs, but I have never come across functions from third-party libraries not working. In the optimized build the error says: Uncaught TypeError: http://this.Th is not a function                                                                                      main.js:1428    at ZonedDateTime.uP.yd (main.js:1428)    at KS (main.js:1424)    at Instant.hP.yd (main.js:1427)    at KS (main.js:1424)


Seeing how there are Instant and ZonedDateTime in the stack trace, the issue is probably with this library, that is a transitive dependency of tick :


Either way, sounds like it would be better to create an issue for tick with a minimal reproducible example.

Christopher Gsell16:08:23

Ok awesome thank you


hello, I maintain tick 🙂


what version of tick do you have?


and what is your build setup?


shadow/figwheel ... etc?

Christopher Gsell16:08:28

we were using version 0.4.23-alpha, and shadow build

Christopher Gsell16:08:22

and btw we love tick so much that it's everywhere in our project, so when we ran the release build we were in for a surprise haha


good to hear!


I think you'll need to bump the version.


Older versions needed some prep to work on shadow

Christopher Gsell17:08:21

Seems to be working - thank you

Christopher Gsell18:08:19

@U051B9FU1 I'm not quite sure why it was working before, but seems to be failing again, even with the latest version. Same error. I'll see if I can create an issue and reproduce it


What's the best practice around uncaught errors in cljs async tests?


e.g. in this case:

(deftest with-out-str-test
  (async done
         (-> (nbb/load-string "[(with-out-str (println :hello))
                                (with-out-str (prn :hello))
                                (xwith-out-str (print :hello))]")
             (.then (fn [val]
                      (is (= [":hello\n" ":hello\n" ":hello"]
             #_(.catch (fn [err]
                         (prn (str err))))
             (.finally done))))
If I didn't put the .catch there, the test suite just seems to pass and the error would go unnoticed.


I've never dealt with such tests but FWIW I have two thoughts: • It should be possible to create an alternative for async that would test if the returned value is a promise and, if so, would automatically add (.catch ...) • The unchandledrejection event ( is dispatched when a promise without a catch errors out. Perhaps, it could be leveraged here.


Thanks. I’ll reuse the 1 isn’t equal to 0 trick. I have made a macro which just wraps the thing in a catch