Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace runtime with emotion.js #57

Open
roman01la opened this issue May 27, 2019 · 6 comments
Open

Replace runtime with emotion.js #57

roman01la opened this issue May 27, 2019 · 6 comments
Labels

Comments

@roman01la
Copy link
Collaborator

CSS-in-JS libraries in JavaScript world are mature enough already so it makes little sense to ignore them. I'd propose to replace library runtime with existing JS library, like Emotion, and make cljss essentially a thin wrapper on top of JS library.

@roman01la roman01la changed the title Proposal: Replace runtime with emotion.js Replace runtime with emotion.js May 27, 2019
@mattly
Copy link

mattly commented Oct 22, 2019

I came here looking for any issues about performance, since a tool I'm using makes heavy use of dynamic styles and I noticed cljss was slowing down the repaints quite a bit.

Replacing cljss with emotion for a single heavily-used dynamic style (that often had to change at least 15 instances on a repaint) took my repaint times from 175ms to 13ms.

@knubie
Copy link

knubie commented Oct 28, 2019

@mattly Would you mind sharing how you're using emotion in your cljs project? Are you using the "vanilla" emotion package, or @emotion/styled or something else?

@roman01la
Copy link
Collaborator Author

I've used the one which is published to cljsjs, guess it's vanilla. The only issue with js lib is that it won't work with SSR on JVM

@knubie
Copy link

knubie commented Oct 29, 2019

I was just wondering if it needed to be used a certain way to take advantage of the performance benefits, but it doesn't seem like emotion/styled is doing anything special over vanilla emotion.

For example I was surprised to see it wasn't using CSS variables, since I figured swapping out css vars would be more performant than generating entirely new classes each time a prop changes.

@mattly
Copy link

mattly commented Oct 30, 2019

I'm using it from npm under shadow-cljs. I replaced my cljss defstyles with a function that called emotion/css in a js primitive, with values determined at call time. My use-case for this particular style could require over 100 variations of it at once, with about 1/5th of those needing repaint on the change of a single value.

@khmelevskii
Copy link

khmelevskii commented Jun 9, 2020

FYI, I created a tiny wrapper for emotion https://github.com/khmelevskii/emotion-cljs and maybe it can be useful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants