Velocity Europe
Oct 3, 2012
Your animation rate should match the refresh rate of your device:
Phones
55-60Hz
Laptops mostly 58-60Hz
but 50Hz in low-power mode
Random monitors
50-62Hz
Frame timing
Frame budget
<script type='text/javascript'> function animate(time) { } requestAnimationFrame(animate); </script>
All this crap happens every 16ms:
What causes you to blow budget?
Dev Tools' Timeline View is your friend!
Remember, JavaScript is single threaded. If:
your requestAnimationFrame callback won't run!
Most of these sources of jank apply to scrolling, too.
Avoid complex input & scroll handlers like the plague!
For exampleRemember: most of a tab is on one thread.
But! Some things can run even when JS is busy.
CSS animation runs on its own. [demo]
This is on Chrome for Android first, everywhere else soon.
Say what you mean:
Like requestAnimationFrame, you get:
Great for:
Two biggest sources of jank we see:
Sometimes you want to go further or you get stuck.
Turn to about:tracing.
Browsers evolve fast.
Architectural best practices are here to stay:
The specifics of what's slow will change.
Use the tools to hunt down jank:
Tom Wiltzius
Product Manager, Chrome Graphics
wiltzius@chromium.org