Independent transform polyfill. Always include? #6
Replies: 5 comments 5 replies
-
Is it possible to include a global stylesheet that accomplishes the creation of the CSS properties that you want to animate, and might this have better browser support? |
Beta Was this translation helpful? Give feedback.
-
I settled on always including it. It does bump the bundlesize to 3kb overall but I decided the number polyfill adds a few other benefits, for instance it could be possible to run one as a "shadow" animation to a WAAPI animation to provide extra lifecycle methods like animateKeyframes((output) => {}, [0, 1]) At this point you can easily provide tree-shakable advanced APIs like this: animateKeyframes((output) => {}, color("#fff", "#000")) |
Beta Was this translation helpful? Give feedback.
-
FWIW, 4k wasn't even a big deal in 2007. Nowadays it's beyond totally fine |
Beta Was this translation helpful? Give feedback.
-
I think that's true if you're making a product and you know your audience but when it's a library you don't even know the product so the audience could be anywhere in the world on any awful connection. Having said that I think the first release will be about 3.2kb for |
Beta Was this translation helpful? Give feedback.
-
Aside: I came across this post from Stefan Judis a while ago which notes that the upcoming CSS spec for individual transform properties has a built-in default order, which seemed worth keeping in mind in terms of alignment of this API. |
Beta Was this translation helpful? Give feedback.
-
Hi all
Motion Concept C supports animating individual transforms (yey!)
Unfortunately, this feature relies on a browser supporting
CSS.registerProperty
(o no)Chromium browsers already support this API, but as for Safari and Firefox - who knows. To take a progressive enhancement approach, Motion will instantly animate in browsers that don't support
CSS.registerProperty
.I didn't feel like this was quite good enough so over the last couple weeks I've been pottering on tiny number-only polyfill that can animate these values in every browser.
The good news is that it's quite small, around 1kb. But this could grow in size if we chose to support non-numeric CSS variables.
However, relative to the rest of the API, that's quite big. It bumps vanilla Motion from 1.7 to 2.7kb, and Motion for React from 3kb to 4kb.
So there's two approaches we could take. One, always include the polyfill. This will be the better DX. Alternatively, offer the polyfill as an optional extra. This would mean smaller bundle sizes by default but a little more scaffolding for people who wanted to opt-in to this behaviour.
Here's what the API might look like:
I'm interested in hearing other people's thoughts in this trade-off between bundlesize and DX. What do you think?
Beta Was this translation helpful? Give feedback.
All reactions