3 ms·
I would hope that the browser would parse all CSS transforms and then use this particular attribute just for Javascript-based transforms.
by Pxtl 12y ago
I would hope that the browser would parse all CSS transforms and then use this particular attribute just for Javascript-based transforms.
- IgorPartola 12y agoI don't see it. If I create something like this: .wide { transition: width 2s; width: 300px; } but don't apply it to any element, then load a remote JavaScript file that adds that class dynamically, no rendering engine will be able to apply this optimization.
- Pxtl 12y agoI was thinking of animations that are applied declaratively in the HTML/CSS itself, not javascript - things like hover.
- IgorPartola 12y agoThe animations that are applied dynamically are the interesting thing. They are the ones more likely to end up being used in performance-critical applications.
- dmmalam 12y agoThis would be caught be live profiling. The same way a JS engine can figure out that a particular function is only called with ints, and then create a specialised version. Admittedly this would run slow the first few times, until the renderer can get enough data.
- IgorPartola 12y agoRunning slowly the first few times is what will-change is trying to avoid. If you read the article, there is an explicit section on applying will-change separately from the actual transformation so that the rendering engine prepares to animate/transform the object ahead of time.