This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-11-21
Channels
- # beginners (5)
- # boot (15)
- # capetown (1)
- # chestnut (2)
- # cljs-dev (9)
- # cljsjs (3)
- # cljsrn (1)
- # clojure (190)
- # clojure-brasil (2)
- # clojure-greece (14)
- # clojure-italy (3)
- # clojure-poland (8)
- # clojure-romania (1)
- # clojure-russia (2)
- # clojure-serbia (3)
- # clojure-spec (38)
- # clojure-uk (98)
- # clojure-ukraine (2)
- # clojurescript (65)
- # clojurex (1)
- # core-async (16)
- # cursive (16)
- # datomic (3)
- # defnpodcast (7)
- # emacs (11)
- # funcool (2)
- # hoplon (16)
- # jobs (1)
- # leiningen (4)
- # lumo (9)
- # off-topic (2)
- # om (1)
- # other-languages (1)
- # protorepl (1)
- # re-frame (50)
- # reagent (16)
- # reitit (32)
- # remote-jobs (1)
- # rum (1)
- # shadow-cljs (73)
- # spacemacs (36)
- # specter (21)
- # sql (6)
- # unrepl (107)
- # untangled (4)
It seems keyword definitions in ClojureScript are not efficient when using advanced compilation. https://clojurians.slack.com/archives/C073DKH9P/p1511250296000174 Is this related to the way that ClojureScript used to define keyword? Can this be improved?
It seems some of my keywords appears twice in the new
function of my advanced compiled js file, probably because of the specs
I used. So thanks @thheller
the keyword appears once but the keyword constructor uses keyword(ns, name, fully-qualified-name, hashcode)
so in case of unqualified keywords the string appears twice.
that could indeed be improved but probably not worth after gzipping and the extra runtime overhead required
learned a lot. Thanks @thheller. That reminds me of the book of closure
says the compiler's objective is the minimal size of gzipped file, not minimal size of compiled file.
it might be worth exploring though. keywords really add up, especially in reagent projects.
even at 500 keywords its just about 2kb diff gzip’d and thats with completely random keywords
so yeah, possible micro optimization but probably not worth since you’ll then have to pay the overhead at runtime to construct the fqn when needed.
@cmal A few years ago the Closure compiler had an option to alias duplicate strings, i.e. create a var and use that. They removed that option since it was found to be no benefit in parsing time and code size after gzip.
yeah it does. I tried messing with it a while ago and pretty much got the same result they got.
It seems that secretary is a bit abandoned, no? https://github.com/gf3/secretary
How do I add or replace a query parameter to the current browser location (without manual string writing)? Can I use Google Closure for this?
hmm, of course that doesn’t work because query parameters can have the same keys to represent an array
@borkdude have you tried goog.uri.utils
ns?
a lot of people use secretary, and it is integrated in lots of popular lein templates, so i don’t think it’s risky to use it
@roman01la I’ve tried this in the browser console:
uri = new goog.Uri(window.location.href)
x = uri.getQueryData()
x.add("foo",2)
uri.toString()
That kind of works, but doesn’t replace the query parameter yet. I think I’d have to do that manually as query params may have multiple by the same name.goog.uri.utils.setParam(location.href, 'q' 'search')
it should also handle arrays, at least docs says it should 🙂
This works, goog.uri.utils.appendParams(location.href, 'q', ['1', '2', '3'])
, but not setParam
anyone using cljs.test in a 'fail-fast' manner? i.e. one test failure causes the rest of the suite to not be run
I see there's *report-counters*
, but while in Clojure that's a real dynamic var, in Clojurescript it's a magic injected var
and I cannot use such vars if I want Figwheel to load my testing ns's into the browser (which is very convenient)
how come: (let [Initialization (aget ApplicationInsights "Initialization")] (Initialization. conf))
work and:
(ApplicationInsights.Initialization. conf) does not?
@hkjels (ApplicationInsights.Initialization. conf)
is not any syntax I recognize (looks like a mixture of JavaScript and ClojureScript). My first reaction would be (new (.-Initialization ApplicationInsights) conf)
or something along the lines of what you did, (let [Initialization (.-Initialization ApplicationInsights)] (Initialization. conf))
, if you wanted to allow Closure renaming (but that seems more verbose).
Yep. Dots at the beginning or end of a symbol are just sugar that the macroexpander converts. Try (macroexpand '(x.))
and (macroexpand '(.x y))
When doing prerender of a single page app in server. Let's say the server computes a reagent component to html, also adds
the app.js script. All this gets downloaded by the browser, the prerendered html is put to the dom and then it
downloads the app.js
, parses it and recomputes+repaints that same component the server returned?
If that so, then while the app.js is being downloaded + parsed + evaluated, the dom is still locked. Ok, you see the initial html but it is unusable. With re-frame or reagent you can't even put app.js script with async option as it uses document.write in its code, which makes async option not to work.
@tomaas yes. one thing you can do is to render as much interactive elements as possible with links and maybe some CSS. So while waiting for JS to load user can go to another page.
but then again you should wait for a bundle to load 😄
@tomaas did you identify what is doing the document.write
? seems like that should be fixed.
@tomaas haha, best solution ever! (seriously) you can do all sorts of optimizations like code splitting etc. but not sure if it’s worth it in your case
@thheller, I didn't. Just seen that there are a few appearances of it in production's (with optimization :advanced option) build.
@tomaas could you point to these in Reagent’s code? Just scanned the code base, couldn’t find anything
anyway, regarding the ultimate user experience I don't see any bad thing about not having anything prerendered on the server, it's just that I noticed that google's pagespeed insights takes away ~20 points for not having the script tag with async option.
however, http://gtmetrix.com doesn't care about that at all
it’s fine unless you are all into “perf matters” Google advocating thing, IMO
@mikethompson My apologies for dropping off the face of the earth; thank you for the pointer and looking into this; I’ll get it working 🙂 thanks again
anyone know of cljs bindings for https://github.com/numjs/numjs ?
Does anyone know, what’s the format that the constructor for https://google.github.io/closure-library/api/goog.i18n.DateTimeFormat.html uses as pattern
? Is it some standard?
Oh, it’s probably like this: http://www.gwtproject.org/javadoc/latest/com/google/gwt/i18n/client/DateTimeFormat.html
@grav Looks like there might be other things like Q
for quarter. Seems odd they don’t just document or provide a link. Here’s what I was looking at: https://github.com/google/closure-library/blob/master/closure/goog/i18n/datetimeformat.js#L868
@mfikes Thanks for the link! You’re right, there’s more to it than just what I found. But who needs docs when you’ve got the nice Javascript source 😉
I'm trying to :require npm dependency (uuid) in browser through figwheel, but it fails because the dependency is not compiled into single file - it's using "require" function. Anyone could help? 🙂
It's failing with "require is not defined" Reference error.
The problem is that in its package.json is:
"browser": {
"./lib/rng.js": "./lib/rng-browser.js",
"./lib/sha1.js": "./lib/sha1-browser.js"
},
which is ignored by compiler -> ends up with unresolved (untouched) require('./lib/rng')
.RE: boot-cljs-test
I am using crisptrutski/boot-cljs-test
and it seems to be crashing because I do not have phantomjs installed locally. Is this correct behaviour? I reviewed the README and it does not suggest anything about installing phantomjs for this to work. The next question is, is this the preferred task for cljs tests or are people more commonly writing their own task?
Interesting. The answer seems to be on the https://github.com/bensu/doo README where it actually tells you that you need to install phantom.