Animations for Web &
Hybrid
@alexblom
Isle of Code
whoami
Isle of Code
• Toronto + Houston based development;
• Focused on Ember/Vue/React/Cordova;
• Creators of ember-cordova & corber;
corber.io
• Extension of ember-cordova;
• Supports Ember, Vue, React, Glimmer;
• CLI for framework -> hybrid builds;
• Adds livereload, unified builds, splash/icons, etc;
corber demo
Contents
• What makes a good animation?;
• Profiling / performance;
• 3 examples;
• Additional options (promoting layers, JS
animation API);
What makes a good
animation?
FPS Target
• 60fps is considered best;
• 1000ms / 60fps = ~16.6ms per frame;
• 60fps is not always achievable!;
• It is better to deliver a consistent frame rate
than a variable one. Consider targeting 30fps;
Animation Options
• Declarative: CSS;
• Generally speaking most performant;
• Browser knows what is happening up front -
can save you from yourself;
• Can become complex to write;
Animation Options
• Imperative: JS;
• Tell the browser how. Easier to spell out in
code (e.g. bounce);
• Run on the main thread (not great);
• requestAnimationFrame & webAnimationsAPI
can fix performance issues - to be discussed
later;
Profiling / Performance
From 0 to rendered
How our content is rendered
• 1: DOM Tree constructed;
• 2: Layout (recursively from the top left);
• highly interdependent;
• expensive;
Layout Styles
width overflow/overflow-y
min-width font-weight
height font-size
min-height text-align
padding line-height
display vertical-align
border white-space
border-width clear
position bottom/top/left/right
float
Reflow
What causes Reflow?
• Resizing the browser window;
• using JavaScript methods involving computed
styles;
• adding or removing elements from the DOM; and
• changing an element's classes.
• https://developers.google.com/speed/articles/reflo
w
How our content is rendered
• 1: DOM Tree constructed;
• 2: Layout (recursively from the top left);
• 3: Paint;
Paint Styles
border-style outline
border-radius outline-color
background outline-width
background-size outline-style
background-image color
background-repeat visibility
background-position text-decoration
box-shadow
Paint Styles
• opacity is a special case;
• If the element has its own layer, this is handled
automagically by lowering the alpha-mask value;
How our content is rendered
• 1: DOM Tree constructed;
• 2: Layout (recursively from the top left);
• 3: Paint;
• 4: Composite/Layering (default is a single layer);
Layers
• Default is a single layer;
• Composed layer more efficient to animate - GPU;
• Pushing every node to it’s own layer is the worst case;
• The most performant is hardware accelerated
properties on composite layers (e.g.
transform/translateX);
• Layers are expensive (width * height * 3);
Promoting a Layer
• will-change property, e.g.;
• will-change: auto;
• will-change: scroll;
• will-change: transform;
Prior Layers
Add will-change;
Layers
Layout Thrashing
Layout Thrashing
Profiler Tool
Profiler Tool
Profiler Tool
Profiler Tool
Profiler Tool
Our Scene
https://www.sitepoint.com/playing-with-fire-organic-css3-animation/
Animation 1 -
The worst case
Animation 1
Animation 1
PG Day Us: Animations for Web & Hybrid
PG Day Us: Animations for Web & Hybrid
PG Day Us: Animations for Web & Hybrid
Some of our problems
• Big FPS dip;
• Each animation is triggering a reflow;
• We are not taking advantage of hardware-
accelerated properties;
• We are redrawing at a fixed (but not) rate;
• Will keep running in an unfocused tab;
We are redrawing at a fixed
rate
• Sort of:
• interval timing is not guaranteed - if our thread
is busy it will take longer;
• When a tab is inactive the interval will still fire
every ~1s;
CSS3 Animations
(@keyframe)
https://www.sitepoint.com/playing-with-fire-organic-css3-animation/
CSS3 Animation
• animation-duration;
• animation-delay;
• animation-timing;
• ease, linear, ease-in, ease-out, ease-in-out,
cubic-bezier;
Why don’t we try them
in this case?
But CSS animations
are hard!
Animation API
PG Day Us: Animations for Web & Hybrid
Animation 2 -
Hardware Accelerated
http://slides.com/ehayman/deck-1#/6
http://slides.com/ehayman/deck-1#/6
Animation 2
PG Day Us: Animations for Web & Hybrid
Timeline
PG Day Us: Animations for Web & Hybrid
Profile
• 6248ms to 5420ms on scripting;
• 10588ms to 4818ms rendering;
• 267ms to 1488ms painting;
Some of our problems
• Big FPS dip (sort of);
• Each animation is triggering a reflow;
• We are not taking advantage of hardware-
accelerated properties;
• Will keep running in an unfocused tab;
• We are redrawing at a fixed rate;
Animation Frames
animationFrame
• Supported for major browsers;
• Only draws when:
• the animation will be visible;
• the browser is ready;
• there are no other frames waiting to be drawn;
• Eliminates unnecessary draws & overloaded
callbacks;
PG Day Us: Animations for Web & Hybrid
animationFrame
animationFrame
PG Day Us: Animations for Web & Hybrid
PG Day Us: Animations for Web & Hybrid
Profile
• 5420ms to 2605ms on scripting;
• 4818ms to 5295ms rendering;
• 1488 to1557ms painting;
Some of our problems
• Big FPS dip;
• Each animation is triggering a reflow;
• We are not taking advantage of hardware-
accelerated properties;
• This will keep running in an unfocused tab;
• We are redrawing at a fixed rate;
Still could be better
• Immediate reaction may be to tear down unused
elements;
• Don’t
PG Day Us: Animations for Web & Hybrid
Demo
PG Day Us: Animations for Web & Hybrid
Profile
• 2605ms to 1068ms on scripting;
• 5295ms to 2100ms rendering;
• 1557 to 702ms painting;
Intersection Observer API
Intersection Observer API
• “The Intersection Observer API provides a way to
asynchronously observe changes in the
intersection of a target element with an ancestor
element or with a top-level document’s.”
• https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API
Intersection Observer API
Intersection Observer API
• callback function receives a list of intersections
detected;
Passive Event Listener
Passive Event Listener
• Allows you to indicate preventDefault will not be
used - e.g. eliminates block on scroll
My best practices
• Avoiding JS Animation API until better Safari support;
• Pages with smaller animations (e.g. button bounce):
• CSS/Hardware accelerated animations are fine;
• Will generally promote frequent/transitional
animations to their own layer;
• Pages with lots of animations:
• Just use animationFrame;
Animations for Web &
Hybrid
@alexblom
Isle of Code

More Related Content

PDF
Famo.us introduction
PDF
WebAssembly vs JavaScript: What is faster?
PDF
Choosing your animation adventure - Generate NYC 2018
PDF
Rubypalooza 2009
KEY
Ruby For Web Development
KEY
HTML5 Video Presentation
PDF
Animations on Fire - Making Web animations fast
PDF
تطوير التطبيقات التفاعلية باستخدام Unity
Famo.us introduction
WebAssembly vs JavaScript: What is faster?
Choosing your animation adventure - Generate NYC 2018
Rubypalooza 2009
Ruby For Web Development
HTML5 Video Presentation
Animations on Fire - Making Web animations fast
تطوير التطبيقات التفاعلية باستخدام Unity

What's hot (12)

PDF
Umbra Ignite 2015: Graham Wihlidal – Adapting a technology stream to ever-evo...
KEY
Sinatra and Heroku - A comfortable ruby way for web service
PDF
Smooth Animations for Web & Hybrid
PPTX
Advanced Silverlight
PPTX
Immutable infrastructure isn’t the answer
PDF
Using Aws As A Game Server (AWS UG Bandung)
PDF
Desktop server presentation
PDF
Awesome html with ujs, jQuery and coffeescript
PDF
Beutiful javascript with coffeescript
PDF
Building Creative Product Extensions with Experience Manager
PDF
Ask the expert - App performance on Series 40 phones
PDF
Umbra Ignite 2015: Jérémy Virga – Dishonored 2 rendering engine architecture ...
Umbra Ignite 2015: Graham Wihlidal – Adapting a technology stream to ever-evo...
Sinatra and Heroku - A comfortable ruby way for web service
Smooth Animations for Web & Hybrid
Advanced Silverlight
Immutable infrastructure isn’t the answer
Using Aws As A Game Server (AWS UG Bandung)
Desktop server presentation
Awesome html with ujs, jQuery and coffeescript
Beutiful javascript with coffeescript
Building Creative Product Extensions with Experience Manager
Ask the expert - App performance on Series 40 phones
Umbra Ignite 2015: Jérémy Virga – Dishonored 2 rendering engine architecture ...
Ad

Similar to PG Day Us: Animations for Web & Hybrid (20)

PPTX
Browser Internals for JS Devs: WebU Toronto 2016 by Alex Blom
PDF
Webapp Rendering and Optimization.
PPTX
From Web to Mobile with Stage 3D
PPTX
Improving Game Performance in the Browser
PDF
Extreme Web Performance for Mobile Devices
PPTX
Fastest css3 animations
PDF
Css3 transitions and animations + graceful degradation with jQuery
PDF
Usersnap and the javascript magic behind the scenes - ViennaJS
PPTX
From HTML to pixels on the Screen
PDF
Adobe AIR for mobile games
PPTX
PPT
Brewing Your Own Game Engie eng
KEY
Rockstar Graphics with HTML5
PPTX
Making a game with Molehill: Zombie Tycoon
PPTX
PhoneGap Day EU 2017: Hybrid Ember Apps
PPTX
20 x Tips to better Optimize your Flash content
PDF
Scratching the itch, making Scratch for the Raspberry Pie
PPTX
External JavaScript Widget Development Best Practices
PPTX
Java scriptwidgetdevelopmentjstanbul2012
KEY
20120802 timisoara
Browser Internals for JS Devs: WebU Toronto 2016 by Alex Blom
Webapp Rendering and Optimization.
From Web to Mobile with Stage 3D
Improving Game Performance in the Browser
Extreme Web Performance for Mobile Devices
Fastest css3 animations
Css3 transitions and animations + graceful degradation with jQuery
Usersnap and the javascript magic behind the scenes - ViennaJS
From HTML to pixels on the Screen
Adobe AIR for mobile games
Brewing Your Own Game Engie eng
Rockstar Graphics with HTML5
Making a game with Molehill: Zombie Tycoon
PhoneGap Day EU 2017: Hybrid Ember Apps
20 x Tips to better Optimize your Flash content
Scratching the itch, making Scratch for the Raspberry Pie
External JavaScript Widget Development Best Practices
Java scriptwidgetdevelopmentjstanbul2012
20120802 timisoara
Ad

More from Alex Blom (9)

PPTX
Ember Conf 2016: Building Mobile Apps with Ember
PPTX
Phonegap Day 2016: Ember/JS & Hybrid Apps Tips
PPTX
Building Browser Extensions with Ember
PPTX
Web Unleashed Toronto 2015: Hybrid Mobile Apps with Ember.js
PPTX
Build email apps with morse.io
PPT
Innovation Growth Strategies for Small Business
PDF
Freelance Camp Toronto: How to sell to Enterprise by Dr Cindy Gordon
PPTX
Freelance Camp Toronto: Social is not new and the 7 biggest social mistakes
PPTX
Ryerson 6th August
Ember Conf 2016: Building Mobile Apps with Ember
Phonegap Day 2016: Ember/JS & Hybrid Apps Tips
Building Browser Extensions with Ember
Web Unleashed Toronto 2015: Hybrid Mobile Apps with Ember.js
Build email apps with morse.io
Innovation Growth Strategies for Small Business
Freelance Camp Toronto: How to sell to Enterprise by Dr Cindy Gordon
Freelance Camp Toronto: Social is not new and the 7 biggest social mistakes
Ryerson 6th August

Recently uploaded (20)

PDF
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
PDF
iTop VPN Crack Latest Version Full Key 2025
PPTX
Oracle Fusion HCM Cloud Demo for Beginners
PDF
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
PPTX
CNN LeNet5 Architecture: Neural Networks
PPTX
Computer Software - Technology and Livelihood Education
PPTX
Trending Python Topics for Data Visualization in 2025
PDF
AI Guide for Business Growth - Arna Softech
PDF
Wondershare Recoverit Full Crack New Version (Latest 2025)
PDF
Time Tracking Features That Teams and Organizations Actually Need
PDF
Multiverse AI Review 2025: Access All TOP AI Model-Versions!
PDF
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
PDF
Cost to Outsource Software Development in 2025
PDF
How Tridens DevSecOps Ensures Compliance, Security, and Agility
PPTX
Introduction to Windows Operating System
PPTX
Advanced SystemCare Ultimate Crack + Portable (2025)
PPTX
Weekly report ppt - harsh dattuprasad patel.pptx
PDF
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
PPTX
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
PPTX
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
iTop VPN Crack Latest Version Full Key 2025
Oracle Fusion HCM Cloud Demo for Beginners
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
CNN LeNet5 Architecture: Neural Networks
Computer Software - Technology and Livelihood Education
Trending Python Topics for Data Visualization in 2025
AI Guide for Business Growth - Arna Softech
Wondershare Recoverit Full Crack New Version (Latest 2025)
Time Tracking Features That Teams and Organizations Actually Need
Multiverse AI Review 2025: Access All TOP AI Model-Versions!
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
Cost to Outsource Software Development in 2025
How Tridens DevSecOps Ensures Compliance, Security, and Agility
Introduction to Windows Operating System
Advanced SystemCare Ultimate Crack + Portable (2025)
Weekly report ppt - harsh dattuprasad patel.pptx
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
WiFi Honeypot Detecscfddssdffsedfseztor.pptx

PG Day Us: Animations for Web & Hybrid

Editor's Notes

  • #15: dependent on more than just their node
  • #38: Observe fire keeps gong as thread clogs
  • #67: ADD EXAMPLE OF TAB
  • #68: ADD EXAMPLE OF TAB
  • #69: ADD EXAMPLE OF TAB