This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-03-25
Channels
- # aws (1)
- # beginners (60)
- # boot (12)
- # cider (7)
- # cljs-dev (8)
- # cljsrn (24)
- # clojure (169)
- # clojure-nl (1)
- # clojure-russia (3)
- # clojure-spec (15)
- # clojure-switzerland (1)
- # clojure-uk (24)
- # clojurescript (120)
- # core-async (9)
- # datomic (3)
- # emacs (2)
- # gsoc (3)
- # klipse (2)
- # leiningen (4)
- # numerical-computing (13)
- # off-topic (95)
- # om (7)
- # onyx (1)
- # powderkeg (2)
- # protorepl (2)
- # re-frame (6)
- # reagent (58)
- # ring-swagger (1)
- # rum (28)
- # untangled (42)
- # vim (6)
A generous sprinkling of {}
in my rum app has just saved me 83.8kB in code size (4.2kB compressed). That's pretty impressive. I'm thinking about updating the Rum docs.
@rauh: yes. My coworker gave me that hint. Turns out the compiler is too trigger-happy with code inlining and in some cases you get exponential increase (strings included 4 times).
Yeah I stripped the sablono interpreter completely, either it compiles into React.createElement
calls or it will give me an error.
Saved a bunch of kb and allows me to be more flexible with returning vectors of react elements
Well the downside is you have to manually add some (html ...)
macro calls to your code or it won't work
I also have my own defc
that creates the component lazily (`delay`). Saves 100ms on startup time for me
So with my hacks, you can do
(if foo?
[[:span {} "one"]
[:span {} "two"]]
[:div "else"])
I wonder about replacing for
with mapv
though — should I use mapv
or map
? Does anybody care? Is one better/faster?
well, I don't want to go overboard with these optimizations: code readability is very important for me
But I guess in this case it would be fine to replace the for
or mapv
with something that directly creates a JavaScript array, I'm not going to do anything else with it anyway.
Well IMO for is much more readable than mapv (which also needs html
since sablono can't walk into functions)
That' why I created some macros: https://gist.github.com/rauhs/d49d6f8a6f5fbb8230647c5b2ac210b2
Yes, that's why I've been using it. But replacing it with mapv
produces significant savings (I've just checked).
Yeah, I don't use for
ever (I wrote the "optimizations" page on sablono). It's nuts the code it produces
I do have to be careful, though… More and more of my code is being migrated to .cljc
files, as I'm doing server-side rendering for many things.
Total code size reduction for today (not using your macros yet): 115.6kB, or 11kB gzipped. That's 5.5% of the total.
@rauh @jrychter have you guys seen this? https://github.com/tonsky/rum/issues/128 — was quite surprised to learn components aren’t properly DCE’d
Yes, this has been opened by precisely the coworker I mentioned :-) He alerted me to the '{}' issue.
Ha! This stuff is tricky, you really need to watch what you’re doing...
@martinklepsch I have, I played around with it for like 30min this morning. No clue why it's not DCE'd. 😕