SlideShare a Scribd company logo
Front-end Dev & Designer
at Lunar Logic
Anna Migas
Anna Migas
@szynszyliszys
Make your animations
perform well
zdjęcie krzeseł
http://ancorathemes.com/
Don’t use animations
if they are not helping anyone
How browser renders a website?
First render
First render
Layers
First render
GPU accelerationLayers
Any change on a page
Any change on a page
1. We change layout
(width, margin-top, left)
2. We change paint
(background-color, box-shadow, background-image)
3. We change compositing
(transform, opacity)
https://csstriggers.com/
transform, opacity
The two properties to animate nicely
zdjęcie krzeseł
margins + box-shadow transforms + opacity
Layer promotion
Layers creation
Layers creation
What creates new layers?
1. 3D or perspective transforms
2. Animated 2D transforms or opacity
3. Being on top/a child of a compositing layer
4. Accelerated CSS filters
5. In special cases <video>, <canvas>, plugins
@keyframes rotate {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
.btn {
background-color: white;
border: 1px solid blue;
}
.btn:hover {
-webkit-animation: rotate 1s infinite;
animation: rotate 1s infinite;
}
Web Zurich - Make your animations perform well
Web Zurich - Make your animations perform well
What creates new layers?
1. 3D or perspective transforms
2. Animated 2d transforms or opacity
3. Being on top/a child of a compositing layer
4. Accelerated CSS filters
5. In special cases <video>, <canvas>, plugins
What creates new layers?
1. 3D or perspective transforms
2. Animated 2d transforms or opacity
3. Being on top/a child of a compositing layer
4. Accelerated CSS filters
5. In special cases <video>, <canvas>, plugins
6. will-change property
@keyframes rotate {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
.btn {
background-color: white;
border: 1px solid blue;
will-change: transform;
}
.btn:hover {
-webkit-animation: rotate 1s infinite;
animation: rotate 1s infinite;
}
Web Zurich - Make your animations perform well
will-change rules
1. Give a browser a moment to think
.btn {
transition: transform 1s ease-out;
background-color: white;
border: 1px solid blue;
opacity: 0.7;
will-change: opacity;
}
.btn:hover,
.btn:focus {
opacity: 1;
}
will-change rules
1. Give a browser a moment to think
2. Don’t try to optimise too many elements
*,
*::before,
*::after {
will-change: all;
}
DON’T EVER DO THIS.
Every layer consumes memory.
Use them wisely.
will-change rules
1. Give a browser a moment to think
2. Don’t try to optimise too many elements
3. Use it in stylesheets only if the change will
happen constantly
will-change rules
1. Give a browser a moment to think
2. Don’t try to optimise too many elements
3. Use it in stylesheets only if the change will
happen constantly
4. It is a good idea to remove it once the
animation is finished
var element = document.getElementById(‘element’);
element.addEventListener(‘mouseenter’, hintBrowser);
element.addEventListener('animationEnd', removeHint);
function hintBrowser() {
this.style.willChange = 'transform';
}
function removeHint() {
this.style.willChange = 'auto';
}
will-change rules
1. Give a browser a moment to think
2. Don’t try to optimise too many elements
3. Use in the stylesheets if the change happens
constantly
4. Remove it once the animation is finished
5. Not supported in IE & Edge (you can use
-webkit-transform: translate3d(0,0,0);)
FLIP technique
First
Last
Invert
Play
FLIP technique
A B
0 200px
FLIP technique
A B
0 200px
-200px 0
B A
.element {
position: absolute;
}
.element
B A
.element {
position: absolute;
transform: translateX(-200px);
}
.element
B A
.element {
position: absolute;
transform: translateX(-200px);
transition: transform 1s;
}
.element
B A
.element {
position: absolute;
transform: translateX(-200px);
transition: transform 1s;
}
.element.active {
transform: none;
}
.element
B A
.element {
position: absolute;
transform: translateX(-200px);
transition: transform 1s;
}
.element.active {
transform: none;
}
.element
.active
100ms gap
FLIP technique
FLIP technique
1. Can make a difference on less powerful devices
FLIP technique
1. Can make a difference on less powerful devices
2. Use it for animations that will happen on user
input
FLIP technique
1. Can make a difference on less powerful devices
2. Use it for animations that will happen on user
input
3. https://github.com/googlechrome/flipjs
FLIP technique
1. Can make a difference on less powerful devices
2. Use it for animations that will happen on user
input
3. https://github.com/googlechrome/flipjs
4. https://github.com/szynszyliszys/repaintless
FLIP technique
1. Can make a difference on less powerful devices
2. Use it for animations that will happen on user
input
3. https://github.com/googlechrome/flipjs
4. https://github.com/szynszyliszys/repaintless
5. https://aerotwist.com/blog/flip-your-animations/
requestAnimationFrame()
requestAnimationFrame()
1000ms/60 = 16ms
1 frame
Web Zurich - Make your animations perform well
without requestAnimationFrame()
without requestAnimationFrame()
without requestAnimationFrame()
with requestAnimationFrame()
requestAnimationFrame
function repeated() {
// do something many times
window.requestAnimationFrame(repeated);
}
window.requestAnimationFrame(repeated);
requestAnimationFrame
1. Doesn’t need vendor prefixes any more
2. You need the polyfill to support old browsers
3. Don’t need to use that if you are using: Web
Animation API, Greensock AP, jQuery 3.0.0+
4. cancelAnimationFrame to end scheduling
5. Browser doesn’t play the animation if the tab is
not visible
A B
B A
A
Test your animations
A B
B A
Web Zurich - Make your animations perform well
Web Zurich - Make your animations perform well
Web Zurich - Make your animations perform well
Web Zurich - Make your animations perform well
Web Zurich - Make your animations perform well
Web Zurich - Make your animations perform well
Summary
1. Don’t overuse animations
2. Animate only transform and opacity if possible
3. Use will-change, requestAnimationFrame,
FLIP when applicable
4. Don’t overuse layers
5. Animate elements that are at the top layers
6. Test animations before optimising
Resources
1. https://www.html5rocks.com/en/tutorials/speed/high-performance-
animations
2. http://jankfree.org
3. https://dev.opera.com/articles/css-will-change-property
4. http://creativejs.com/resources/requestanimationframe
5. https://www.udacity.com/course/browser-rendering-optimization--
ud860
6. https://www.html5rocks.com/en/tutorials/speed/layers
7. https://developers.google.com/web/fundamentals/design-and-ui/
animations
Thanks!
Anna Migas
@szynszyliszys

More Related Content

PPTX
Media Evaluation: Part 3
PPTX
1. Production Experiments
PPTX
The Present & Future of Augmented Reality + How to make your first AR app
PDF
HalfStack London - Make Your Animations Perform Well
PDF
Make your animations perform well
PDF
Make your animations perform well - Anna Migas - Codemotion Rome 2017
PDF
Make Your Animations Perform Well - JS Conf Budapest 2017
PDF
Mastering CSS Animations
Media Evaluation: Part 3
1. Production Experiments
The Present & Future of Augmented Reality + How to make your first AR app
HalfStack London - Make Your Animations Perform Well
Make your animations perform well
Make your animations perform well - Anna Migas - Codemotion Rome 2017
Make Your Animations Perform Well - JS Conf Budapest 2017
Mastering CSS Animations

Similar to Web Zurich - Make your animations perform well (20)

PDF
Css3 transitions and animations + graceful degradation with jQuery
PDF
NordicJS: Fast but not Furious: Debugging User Interaction Performance Issues
PDF
Performance.now() fast but not furious
PDF
Fast but not furious: debugging user interaction performance issues
PDF
Super Smooth Animations
PDF
Fullstack 2018 - Fast but not furious: debugging user interaction performanc...
PDF
HalfStack fast but not furious
PPTX
CSS3 TTA (Transform Transition Animation)
PPTX
Fastest css3 animations
PDF
Interface Styling & Scripting on WebKit Mobile
PDF
DotNetNuke World CSS3
PDF
Animations on Fire - Making Web animations fast
PPTX
Chapter 18: Transitions, Transforms, and Animation
PDF
Performant, accessible animations with CSS & a dash of JavaScript
PPTX
CSS3 Animation for beginners - Imrokraft
PDF
Performance beyond page load - CSS Conf Asia 2015
PPTX
Netflix Webkit-Based UI for TV Devices
PDF
Class 4 handout w css3 using j fiddle
PDF
Beyond the Standards
PDF
Responsive Design: Building for a Modern Web
Css3 transitions and animations + graceful degradation with jQuery
NordicJS: Fast but not Furious: Debugging User Interaction Performance Issues
Performance.now() fast but not furious
Fast but not furious: debugging user interaction performance issues
Super Smooth Animations
Fullstack 2018 - Fast but not furious: debugging user interaction performanc...
HalfStack fast but not furious
CSS3 TTA (Transform Transition Animation)
Fastest css3 animations
Interface Styling & Scripting on WebKit Mobile
DotNetNuke World CSS3
Animations on Fire - Making Web animations fast
Chapter 18: Transitions, Transforms, and Animation
Performant, accessible animations with CSS & a dash of JavaScript
CSS3 Animation for beginners - Imrokraft
Performance beyond page load - CSS Conf Asia 2015
Netflix Webkit-Based UI for TV Devices
Class 4 handout w css3 using j fiddle
Beyond the Standards
Responsive Design: Building for a Modern Web
Ad

More from Anna Migas (8)

PDF
Thinking Beyond Core Web Vitals - Web performance optimisations for the harsh...
PDF
Demystifying web performance tooling and metrics
PDF
Secret Web Performance Metric - DevDayBe
PDF
Web performance optimisations for the harsh conditions.pdf
PDF
Secret performance metric - Modern Frontends
PDF
Secret Performance Metric - Armada JS.pdf
PDF
The secret web performance metric no one is talking about
PDF
Be brave and Open Source
Thinking Beyond Core Web Vitals - Web performance optimisations for the harsh...
Demystifying web performance tooling and metrics
Secret Web Performance Metric - DevDayBe
Web performance optimisations for the harsh conditions.pdf
Secret performance metric - Modern Frontends
Secret Performance Metric - Armada JS.pdf
The secret web performance metric no one is talking about
Be brave and Open Source
Ad

Recently uploaded (20)

PPTX
Essential Infomation Tech presentation.pptx
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
top salesforce developer skills in 2025.pdf
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
System and Network Administration Chapter 2
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
Nekopoi APK 2025 free lastest update
PDF
System and Network Administraation Chapter 3
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
L1 - Introduction to python Backend.pptx
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
Operating system designcfffgfgggggggvggggggggg
Essential Infomation Tech presentation.pptx
Design an Analysis of Algorithms II-SECS-1021-03
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
top salesforce developer skills in 2025.pdf
Adobe Illustrator 28.6 Crack My Vision of Vector Design
System and Network Administration Chapter 2
How to Choose the Right IT Partner for Your Business in Malaysia
CHAPTER 2 - PM Management and IT Context
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Upgrade and Innovation Strategies for SAP ERP Customers
How Creative Agencies Leverage Project Management Software.pdf
Nekopoi APK 2025 free lastest update
System and Network Administraation Chapter 3
Design an Analysis of Algorithms I-SECS-1021-03
Odoo Companies in India – Driving Business Transformation.pdf
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
L1 - Introduction to python Backend.pptx
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Operating system designcfffgfgggggggvggggggggg

Web Zurich - Make your animations perform well