Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Super Smooth Animations
Search
Giacomo "Giko" Zinetti
March 16, 2018
Programming
1
100
Super Smooth Animations
Speech for CSSDay in Faenza (Italy)
March, 16th 2018
Live on
https://cssday2018.slides.giko.it/
Giacomo "Giko" Zinetti
March 16, 2018
Tweet
Share
More Decks by Giacomo "Giko" Zinetti
See All by Giacomo "Giko" Zinetti
Cmd Alt I - Chrome Dev tools
gcmznt
0
75
ES2015 new features
gcmznt
0
52
CSS from the future
gcmznt
0
38
Web performance & Http2
gcmznt
0
58
CSS variables
gcmznt
2
110
CSS Performance
gcmznt
2
81
Other Decks in Programming
See All in Programming
Tool Catalog Agent for Bedrock AgentCore Gateway
licux
6
2.5k
AIでLINEスタンプを作ってみた
eycjur
1
230
GitHubとGitLabとAWS CodePipelineでCI/CDを組み比べてみた
satoshi256kbyte
4
240
モバイルアプリからWebへの横展開を加速した話_Claude_Code_実践術.pdf
kazuyasakamoto
0
330
Namespace and Its Future
tagomoris
6
700
Flutter with Dart MCP: All You Need - 박제창 2025 I/O Extended Busan
itsmedreamwalker
0
150
print("Hello, World")
eddie
2
530
Reading Rails 1.0 Source Code
okuramasafumi
0
240
請來的 AI Agent 同事們在寫程式時,怎麼用 pytest 去除各種幻想與盲點
keitheis
0
120
Android 16 × Jetpack Composeで縦書きテキストエディタを作ろう / Vertical Text Editor with Compose on Android 16
cc4966
2
230
FindyにおけるTakumi活用と脆弱性管理のこれから
rvirus0817
0
520
実用的なGOCACHEPROG実装をするために / golang.tokyo #40
mazrean
1
280
Featured
See All Featured
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
8
920
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.1k
Building Better People: How to give real-time feedback that sticks.
wjessup
368
19k
Gamification - CAS2011
davidbonilla
81
5.4k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
229
22k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Unsuck your backbone
ammeep
671
58k
What’s in a name? Adding method to the madness
productmarketing
PRO
23
3.7k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.1k
Transcript
Super smooth animations
Expectation Expectation
Reality Reality
Battery drain Battery drain
Device Device overheating overheating
Maillard Maillard
Giacomo Zinetti Giacomo Zinetti @gcmznt @gcmznt
How browser How browser renders? renders?
Render Render cycle cycle JavaScript JavaScript Style Style Layout Layout
Paint Paint Composite Composite
Our logic Our logic JavaScript JavaScript Style Style Layout Layout
Paint Paint Composite Composite
margin margin padding padding Reflow Reflow JavaScript JavaScript Style Style
Layout Layout Paint Paint Composite Composite
color color background background Repaint Repaint JavaScript JavaScript Style Style
Layout Layout Paint Paint Composite Composite
transform transform opacity opacity Compose Compose JavaScript JavaScript Style Style
Layout Layout Paint Paint Composite Composite
CSS CSS
Animate Animate compositor-only compositor-only properties properties
Execute long JS task Start heavy JS loop Left Translate
Create layers Create layers will-change will-change
❌ ❌ * { * { will-change: transform; will-change: transform;
} }
Disable hover Disable hover on scroll on scroll
JS JS
Avoid forced Avoid forced synchronous synchronous layout layout
❌ ❌ elements.forEach(el => { elements.forEach(el => { el.querySelector('img').style.width el.querySelector('img').style.width
= `${el.offsetWidth}px`; = `${el.offsetWidth}px`; }) })
elements.forEach((el, i) => { elements.forEach((el, i) => { ws[i] =
el.offsetWidth; ws[i] = el.offsetWidth; }) }) elements.forEach((el, i) => { elements.forEach((el, i) => { el.querySelector('img').style.width el.querySelector('img').style.width = `${ws[i]}px`; = `${ws[i]}px`; }) })
rAF rAF requestAnimationFrame() requestAnimationFrame()
rIC rIC requestIdleCallback() requestIdleCallback()
Split big tasks Split big tasks
Web workers Web workers
TARGET TARGET RAIL RAIL
Response <100ms Response <100ms Animation <16ms Animation <16ms Idle <50ms
Idle <50ms Load <1000ms Load <1000ms
FLIP FLIP by @aerotwist by @aerotwist
First First const first = const first = el.getBoundingClientRect(); el.getBoundingClientRect();
Last Last el.classList.toggle('end'); el.classList.toggle('end'); const last = const last =
el.getBoundingClientRect(); el.getBoundingClientRect();
Invert Invert const invert = const invert = first.height /
last.height; first.height / last.height;
Play Play el.animate([ el.animate([ { transform: `scale(${invert}px)` }, { transform:
`scale(${invert}px)` }, { transform: 'scale(0)' } { transform: 'scale(0)' } ], 300); ], 300);
First First Last Last Invert Invert Play Play
None
Content Content VS VS Animations Animations
Users! Users!
The best animation The best animation is the invisible one
is the invisible one Thank you Thank you
Links Links This slides Codepen examples Feedbacks are welcome! Web
Fundamentals: Performance CSS Triggers FLIP by @aerotwist