Performance
Setting an Animation Budget That Protects Core Web Vitals
An animation budget is a hard cap on how much main-thread work, concurrent tweens and JavaScript weight motion is allowed to consume, so animation protects Core Web Vitals instead of breaking them. In my GSAP and WordPress builds I budget for 60fps, keep frames under 16.7ms and long tasks under 50ms, then verify INP at the 75th percentile. That is a practical target, not a guarantee.
What an animation budget actually is
Animation does not appear as its own Core Web Vital, yet it decides whether the three metrics pass. An animation budget is a written ceiling on four things: main-thread milliseconds spent per frame, how many tweens may run at once, which CSS properties motion may touch, and how many kilobytes of animation library ship on a page. Exceed the ceiling and a tap waits behind a long task, INP rises past 200ms, or a layout-animating tween registers as CLS. In my GSAP and WordPress builds the budget is agreed before the first timeline is written, not after a poor field report. It turns "make it move" into a testable constraint: motion is allowed only if it stays inside the frame budget and leaves input responsive.
- A frame ceiling: roughly 16.7ms at 60fps, with under 10ms left for my code
- A long-task ceiling: no single main-thread task above 50ms
- A property allowlist: transform and opacity, never width, height or top
- A library ceiling: GSAP loaded only on routes that animate
Frame rate targets and the 50ms long-task line
Sixty frames per second gives the browser 16.7ms to produce each frame, and that allowance covers style, layout, paint and compositing before my JavaScript runs. I therefore treat 10ms of animation work per frame as the real ceiling, leaving headroom for the rest of the pipeline. On a mid-range Android phone, a 120fps target is usually unrealistic, so I budget 60fps and accept a 30fps floor only for background decoration. A long task is any main-thread block over 50ms; a chain of them during a tap is what pushes INP beyond its 200ms good threshold. Total Blocking Time in the lab is the sum of the over-50ms portions of those tasks, so keeping tasks short improves both metrics.
- 60fps target = 16.7ms per frame; keep animation code under about 10ms
- 30fps floor acceptable only for non-interactive background motion
- Long task defined as any main-thread task above 50ms
- INP good at 200ms or less (p75); TBT goal at 200ms or less in the lab
- Budget against a mid-range Android profile, not a desktop workstation
Choose properties the compositor can handle
The fastest animation is the one the browser never has to lay out again. transform and opacity can run on the compositor thread, so they keep moving even when the main thread is busy with a click handler. Animating width, height, top, left, margin or box-shadow forces layout and paint on every frame, which both burns the frame budget and can register unexpected layout shift. In GSAP I set force3D: true where appropriate, add will-change only to elements that actually animate and remove it afterwards, and avoid stacking dozens of promoted layers. I also keep animated elements out of the normal flow where possible so a tween cannot nudge neighbouring content and inflate CLS.
- Animate transform and opacity; treat width, height, top and left as banned
- Avoid animating box-shadow and blur filters on every frame
- Add will-change only to active elements and clear it when the tween ends
- Reserve space for animated blocks so motion cannot shift neighbours
- Use GSAP force3D for layer promotion, but do not promote every element
Keep input responsive: long tasks, INP and animation
INP measures the worst meaningful interaction in a visit — input delay, handler time and the next paint together — so a beautiful timeline that hogs the main thread fails it. I watch long tasks with a PerformanceObserver subscribed to the 'longtask' entry type, and I read the exact offending element from the web-vitals library's onINP attribution build. The fixes are structural: split handlers into chunks under 50ms, yield between them with scheduler.postTask() or a zero-delay setTimeout, and pause or slow decorative timelines while a user is typing or tapping. I load third-party widgets on interaction rather than on page load, and I kill timelines on navigation with gsap.context() so orphaned tweens do not keep running.
- Observe "longtask" entries with PerformanceObserver to find main-thread stalls
- Use onINP attribution to name the target element behind a slow interaction
- Split handlers under 50ms and yield with scheduler.postTask() or setTimeout(0)
- Pause decorative timelines during input; load widgets on interaction
- Kill tweens on route change with gsap.context() clean-up
How I measure an animation budget
I measure in two passes. In the lab, I record a DevTools Performance trace on a mid-range Android profile with 4x CPU and 4G throttling, then read the Frames track, the Main activity lane and the animation frame rate overlay. I confirm no task crosses 50ms during a scripted tap and that the frame rate holds near 60fps while the sequence plays. For field truth I send onINP, onLCP and onCLS values from the web-vitals library to analytics with attribution, and I compare the 75th percentile against the Chrome User Experience Report. A lab pass with a failing field p75 means the test device was too generous.
- DevTools Performance trace with 4x CPU and 4G throttling
- Rendering > Frame Rendering Stats for a live fps meter
- PerformanceObserver for long tasks and web-vitals onINP attribution in RUM
- CrUX and PageSpeed Insights field p75 as the verdict
- Lighthouse CI or WebPageTest budgets that fail a build on TBT or INP regression
Where the budget lives in a WordPress and GSAP build
I keep the budget in code and in a short document, not in a slide. GSAP is enqueued only on templates that use motion, through wp_enqueue_scripts with a version argument, and deferred with script_loader_tag so it cannot block the LCP element. Plugins register only the timeline they need; a single shared helper exposes the 10ms frame ceiling and the 50ms task ceiling as named constants that reviewers can see. I respect prefers-reduced-motion both in CSS and by skipping timeline creation in JavaScript. The document records the allowed properties, the maximum number of simultaneous tweens, and the kilobyte ceiling, so a new animation is checked against it before merge.
- Enqueue GSAP only where used; defer it via script_loader_tag
- Keep motion constants and the allowlist beside the code, version-controlled
- Honour prefers-reduced-motion in CSS and skip timelines in JS
- Cap concurrent tweens and total animation JavaScript weight
Trade-offs, verification and the release checklist
Motion always trades against responsiveness. Staggering a reveal improves perceived polish but lengthens the time the main thread is busy; a long parallax can look premium and still fail INP on a mid-range phone. I accept fewer simultaneous effects, shorter durations and a reduced-motion path before I accept a metric regression. Before release I re-run the trace, check the field p75 after the 28-day window rolls over, and confirm the LCP image was not delayed by an animation library. I am Saif Al Jahan of webdev-saif.com, a WordPress and PHP developer in Mymensingh, Bangladesh (GMT+6). These are practical targets from my builds, not guaranteed rankings.
- Prefer fewer, shorter effects over many simultaneous tweens
- Re-measure field p75 after the 28-day window, not just the lab trace
- Confirm animation JavaScript does not delay LCP or add CLS
- Ship a reduced-motion path and verify it with the OS setting enabled
Frequently asked questions
Does animation affect Core Web Vitals?
Not directly — there is no animation metric — but it drives all three. A tween that animates layout can raise CLS, a heavy GSAP timeline can create long tasks that push INP past 200ms, and a blocking animation library can delay LCP. An animation budget sets limits on each so motion stays inside the Core Web Vitals thresholds.
What frame rate should I target for web animation?
Target 60fps, which gives the browser 16.7ms per frame. I keep my own animation code under about 10ms so style, layout and paint still fit. On mid-range Android hardware I accept a 30fps floor only for decorative background motion. A 120fps target sounds impressive but rarely survives field conditions on typical devices.
What counts as a long task and why does it matter?
A long task is any main-thread job running more than 50 milliseconds. During an interaction, a chain of them delays the next paint and raises INP. Watch them with a PerformanceObserver on the 'longtask' entry type, split handlers under 50ms and yield between chunks. Lower Total Blocking Time in the lab follows automatically.
How do I measure animation performance in the field?
Use the web-vitals JavaScript library to record onINP, onLCP and onCLS from real sessions and send them to analytics with attribution data. Compare the 75th percentile with the Chrome User Experience Report in PageSpeed Insights. DevTools traces and Lighthouse are for reproduction; field data at p75 is what decides whether your budget holds.
Should I use transform and opacity only?
For most UI motion, yes. transform and opacity can be composited without layout or paint on every frame, which protects both frame rate and CLS. Animating width, height, top or left forces the browser to redo layout. If you must animate a layout property, do it once off-screen and reserve the final space before the element appears.
How does prefers-reduced-motion fit into the budget?
It is part of the budget, not an optional extra. I check the media query in CSS and also in JavaScript before creating a timeline, so users who request reduced motion get a static or cross-fade state instead of full movement. It removes all frame cost for those visitors and is the simplest accessibility win in an animation system.