A designer asks for animations that stay smooth on a 60 Hz display and on a 120 Hz laptop. How much wall-clock time does one frame give you at each refresh rate, and why is the budget for your own work smaller than that number?
answer
- one over the refresh rate
- the browser takes a cut
- not the whole interval is yours
- about ten milliseconds at sixty hertz
- half again at 120 Hz
basics
~20 sA frame lasts about 16.7 ms at 60 Hz and about 8.3 ms at 120 Hz. The browser needs part of every frame for its own style, layout, paint and compositing work, so budget only around half of it — roughly 8-10 ms at 60 Hz — for your code.
solid answer
~50 sThe frame interval is just `1000 / refreshRate` milliseconds: ~16.7 ms at 60 Hz, ~11.1 ms at 90 Hz, ~8.3 ms at 120 Hz. That whole interval is not yours, though. Inside it the browser still has to recalculate style, run layout, paint and composite, and it shares the thread with timers, event handlers and garbage collection. The common rule of thumb — it comes from Google's RAIL guidance — is to keep your own per-frame work under about 10 ms at 60 Hz and to treat anything above that as borrowed time. If the frame is not ready when the display refreshes, it is not shown a little late; the previous image simply stays on screen, and the user reads that as a stutter. So the practical target is not "be fast on average" but "never overrun", which is why per-frame budgets are stated as a ceiling and checked on the slowest device you support, not on a developer laptop.
go deeper
Be ready to produce the numbers instantly: about 16.7 ms per frame at 60 Hz and about 8.3 ms at 120 Hz, from 1000 divided by the refresh rate. Say plainly that some of that time belongs to the browser.
Explain what consumes the rest of the frame — style, layout, paint, compositing, plus timers and garbage collection on the same thread — and why roughly 10 ms at 60 Hz is the usual planning figure for your own work.
Show that you check the budget on a slow reference device rather than a laptop, that you judge animations by their worst frames rather than an average, and that you know a high refresh rate often comes with a slower CPU.
Own the policy: which device tier the budget is defined against, what number the team is allowed to ship, and how that ceiling is enforced so a motion-heavy feature cannot quietly borrow the whole frame.
## What a frame actually is A display refreshes at a fixed rate — 60 times a second on most desktop monitors, 90 or 120 on many phones and newer laptops. Each refresh shows whatever image the graphics system has ready at that moment. The browser's job during an animation is to have a new image ready before every refresh. "60 fps" is therefore not a browser setting or a quality slider; it is a deadline imposed by the hardware. ## The arithmetic The interval between refreshes is `1000 / refreshRate` milliseconds: ``` 60 Hz -> 1000 / 60 = 16.67 ms 90 Hz -> 1000 / 90 = 11.11 ms 120 Hz -> 1000 / 120 = 8.33 ms 144 Hz -> 1000 / 144 = 6.94 ms ``` Those are the only numbers worth memorising, and 16.7 / 8.3 are the two you will be asked for. ## Why the whole interval is not yours Inside that window the browser has to do everything, not just run your callback. It recalculates styles for elements whose properties changed, runs layout if anything affected geometry, paints the changed areas, and hands the result to compositing. Those steps take real milliseconds, and they scale with how many elements you touched and how large an area changed. On top of that, the same thread is running your event handlers, timers, promise reactions and any garbage collection the engine decides to do. The widely quoted planning figure — from Google's RAIL performance model — is to leave the browser roughly 6 ms of every 16.7 ms frame and keep your own work under about 10 ms. Treat that as a budget, not a law: the honest version is "your work plus the browser's work must fit, and you only control one half of the sum". ## Overrunning is not a small penalty A frame you fail to deliver is not shown slightly late. The previous image stays on screen for another refresh interval, so the motion visibly hitches. This is why a mean frame time of 12 ms tells you almost nothing: an animation that is comfortably inside budget for 200 frames and blows through it for three still looks broken, and the average hides exactly the frames the user noticed. Budgets for animation are stated as ceilings and checked against the worst frames, not the mean. ## Higher refresh rates make the budget harder, not easier It is tempting to assume a 120 Hz device is a fast device. Often it is not: high-refresh panels are common on mid-range phones whose CPUs are several times slower than a developer laptop. That combination is the worst case — half the time per frame, on slower hardware. Some browsers and devices respond by animating at a lower rate, or by throttling on battery saver, so you cannot assume you will be given the top rate either. The practical consequence is that you should never write an animation that assumes a fixed frame interval, and you should pick a *reference device* — a specific mid-tier phone, or a CPU-throttled desktop profile — as the machine the budget must hold on. ## Spending the budget well Once you accept that you own roughly 8-10 ms at 60 Hz and about half that at 120 Hz, the design decisions follow: - **Animate few things, and small areas.** Per-frame cost scales with the number of animating elements and the pixel area the browser must redraw. Ten animating cards cost roughly ten times one. - **Prefer properties the browser can update without redoing layout for the whole page** — `transform` and `opacity` are the two you can nearly always afford, which is why motion systems are usually built out of them. - **Hoist everything constant out of the per-frame path.** Values you can compute once — element sizes, easing tables, DOM references, colour strings — should not be recomputed 60 times a second. - **Avoid per-frame allocation.** Creating objects, arrays or strings each frame gives the garbage collector reasons to run inside your budget. - **Prefer declarative animation where you can**, so there is no per-frame JavaScript in the budget at all. ## How the number shows up in an interview A junior is expected to produce 16.7 ms and, ideally, 8.3 ms. A stronger answer adds the second half: that the browser takes a share, that the effective budget is roughly half the interval, that missing the deadline drops a whole frame rather than delaying it slightly, and that the budget must be verified on a slow reference device rather than the machine you develop on.
- Does a 120 Hz display mean the animation needs to do twice as much work per second?Yes — twice as many frames, each with half the time. And the device is usually not twice as fast; high-refresh panels are common on mid-range phones. Browsers may also drop to a lower animation rate under battery saver or heavy load, so you should target smoothness at the rate you actually get rather than assume the panel's maximum.
- If your per-frame work measures 12 ms on a developer laptop, is that inside budget?On paper it fits a 16.7 ms frame, but it is not safe. The browser still needs its share, and a mid-tier phone can be four to ten times slower on the same code, which puts you far past the deadline. Re-measure with CPU throttling or on a real reference device before calling 12 ms acceptable.
- Your animation must fit a tighter budget. What do you cut first?Cut per-frame work before cutting the animation. Hoist constants and DOM lookups out of the loop, stop allocating objects each frame, reduce how many elements animate and how much screen area changes, and move to properties that do not force the browser to redo layout. Shortening the duration hides the problem rather than fixing it.
saying these in an interview costs you the question
- Says a frame is 16 ms and all of it is yours to spend
- Treats 60 fps as a browser setting rather than the display's refresh rate
- Assumes a 120 Hz device has proportionally faster CPU
- Thinks a missed deadline just shows the frame slightly late
- Reports average fps and calls a stuttering animation smooth