Guide · Performance

How to make scroll animation sites fast on mobile

By Md Mahafuj Alam · Updated

Keep the download small with a frame budget, load light preview frames first and stream HD frames only near the scroll position, and release frames you have scrolled past so a phone never holds hundreds of decoded bitmaps. Give phones their own portrait frames, cap the canvas at a devicePixelRatio of 2, draw once per animation frame, and respect reduced motion. Then measure with Lighthouse or PageSpeed Insights on mobile settings.

Why frame sequences are heavy

A canvas scroll story swaps one still image for the next as the reader scrolls. That gives you exact control over every frame, but it costs twice. First, each frame is a separate file to download. Second, each frame must be decoded into a full bitmap before the canvas can draw it, and that bitmap is far larger than the file.

A video file avoids both costs by compressing across frames, but scrubbing a video element backwards and forwards on scroll is unreliable, which is why most cinematic scroll sites use image sequences. If you are still choosing, see image sequence vs video vs three.js.

Phones feel both costs most: slower networks for the download, less memory for the bitmaps, and slower CPUs for decoding. Everything below targets one of those three.

Set a frame budget before you export

A frame budget is the total weight you allow the sequence, divided by the number of frames. Decide it first, then export to fit, rather than exporting and hoping. The arithmetic is simple:

Frame budgettext
average frame weight = total sequence weight / frame count

Example: a 15 MB budget for 300 frames
15,000 KB / 300 = 50 KB per frame

The two live Motion templates show how different the balance can be:

Published figures for the live templates. Per-frame averages are computed from those figures.
TemplateFramesFrame weightAverage per frameMobile score
Kestra44326 MBabout 59 KB90
Orbitly69116.59 MBabout 24 KB72

Kestra ships 443 frames in 26 MB and scores 90 on mobile. Orbitly ships more frames in less weight and scores 72. Frame weight alone does not set the score: the score measures the whole page, and Orbitly also runs a real-time three.js light layer on top of its footage. How the frames load matters as much as how much they weigh, which is what the next sections cover.

To fit a budget, change one thing at a time: fewer frames first, then smaller dimensions, then lower quality. The frame budget calculator does this arithmetic for you, and the ffmpeg image sequence guide has the export commands.

Do the memory maths: decoded bitmaps

A compressed 60 KB WebP does not stay 60 KB once it is ready to draw. The browser decodes it into raw pixels at 4 bytes each (red, green, blue and alpha). The decoded size depends only on the dimensions:

Decoded size = width × height × 4 bytestext
1920 × 1080 × 4 = 8,294,400 bytes  (about 8.3 MB per frame)
1920 × 1072 × 4 = 8,232,960 bytes  (about 8.2 MB per frame)
 720 × 1280 × 4 = 3,686,400 bytes  (about 3.7 MB per frame)
 640 ×  360 × 4 =   921,600 bytes  (about 0.9 MB per frame)

443 HD frames at 1920 × 1072:
443 × 8,232,960 = 3,647,201,280 bytes  (about 3.6 GB)

No phone browser will hold 3.6 GB of bitmaps for one tab. iOS Safari in particular reloads or crashes a tab that uses too much memory, and Apple does not publish the exact limit, so plan to stay well below it. The fix is to keep only a window of HD frames decoded at any time. Fifteen frames on each side of the current one is 31 frames, about 255 MB at 1920 × 1072, and the same window of 720 × 1280 portrait frames is about 114 MB. These are estimates of bitmap memory only; the browser adds its own overhead.

Load previews first, HD later, and portrait on phones

Two frame tiers

Load a light preview tier first so every scroll position has something to draw within a second or two. Then stream HD frames in and draw them over the previews as they arrive. The reader sees motion straight away and sharpness shortly after. Kestra uses exactly this pattern: light previews load first, then 1920 × 1072 HD frames stream in, loaded nearest the scroll position, with far frames released from memory.

Portrait frames for phones

A landscape frame drawn on a portrait phone is mostly cropped away, yet the phone still downloads and decodes every pixel of it. A separate 9:16 set, such as 720 × 1280, is smaller to download, smaller in memory, and can be framed for the tall screen. Kestra and Orbitly both ship dedicated portrait frames for phones. Pick the set once on load:

frames.tsts
const FRAME_COUNT = 443;
const WINDOW = 15; // HD frames kept on each side of the current frame
const isPortrait = window.matchMedia('(orientation: portrait)').matches;
const dir = isPortrait ? '/frames/portrait' : '/frames';
const file = (i: number) => `frame_${String(i + 1).padStart(4, '0')}.webp`;

// Tier 1: every preview frame, small enough to request up front
const previews = Array.from({ length: FRAME_COUNT }, (_, i) => {
  const img = new Image();
  img.src = `${dir}/preview/${file(i)}`;
  return img;
});

Previews are not free in memory either: 443 frames at 640 × 360 would be about 408 MB if all were decoded at once. Browsers can discard decoded data for images that are not on screen, but keep previews small and soft so the worst case stays modest.

Stream frames nearest the scroll position and release the rest

The HD tier lives in a sliding window around the current frame. Load nearest first, so the frame the reader is looking at arrives before the ones behind it, and close bitmaps that leave the window. Decoding with createImageBitmap gives you an object with an explicit close() method, so you release memory on your schedule instead of waiting for garbage collection.

frames.ts (continued)ts
// Tier 2: HD frames, only near the scroll position
const ready = new Map<number, ImageBitmap>();
const pending = new Set<number>();

async function loadHd(i: number) {
  pending.add(i);
  try {
    const res = await fetch(`${dir}/hd/${file(i)}`);
    const bitmap = await createImageBitmap(await res.blob());
    if (pending.has(i) && !ready.has(i)) {
      ready.set(i, bitmap);
      if (i === drawn) draw(i); // upgrade the frame on screen
    } else {
      bitmap.close(); // released while it was loading
    }
  } finally {
    pending.delete(i);
  }
}

function updateWindow(current: number) {
  const lo = Math.max(0, current - WINDOW);
  const hi = Math.min(FRAME_COUNT - 1, current + WINDOW);
  // Nearest first: current, then +1/-1, +2/-2 ...
  for (let d = 0; d <= WINDOW; d++) {
    for (const i of [current + d, current - d]) {
      if (i >= lo && i <= hi && !ready.has(i) && !pending.has(i)) void loadHd(i);
    }
  }
  // Release everything outside the window
  for (const [i, bitmap] of ready) {
    if (i < lo || i > hi) {
      bitmap.close();
      ready.delete(i);
    }
  }
  for (const i of pending) if (i < lo || i > hi) pending.delete(i);
}

A request already in flight still downloads after it leaves the window; the code simply closes the bitmap when it lands. Start with a small window on phones and grow it only if fast scrolling shows preview frames for too long.

Image formats and preloading

  • WebP is the practical default: small files and quick to encode. AVIF is usually smaller for the same quality but slower to encode and can be slower to decode, which matters when you decode hundreds of frames. JPEG is the fallback with the widest support.
  • Do not preload every HD frame with <link rel="preload">. Hundreds of high-priority requests compete with your fonts, CSS and hero image and push back Largest Contentful Paint.
  • Preload only the first frame if it is the first thing on screen, so the opening view paints quickly.
  • Start the HD tier after the page is usable, for example once the previews for the first section have loaded, rather than during the initial render.
  • Serve frames with long cache headers and versioned file names, so a returning visitor does not download them again.

Size the canvas for devicePixelRatio and draw once per frame

A canvas backing store is another bitmap, sized in device pixels. devicePixelRatio is often 3 on phones, so a full-screen canvas of 390 × 844 CSS pixels becomes 1170 × 2532 device pixels, about 11.8 MB. Capped at a ratio of 2, it is 780 × 1688, about 5.3 MB, and on moving footage the difference is hard to see. Capping also means fewer pixels to fill on every draw.

frames.ts (continued)ts
const canvas = document.querySelector('canvas')!;
const ctx = canvas.getContext('2d')!;

function sizeCanvas() {
  const dpr = Math.min(window.devicePixelRatio || 1, 2);
  const rect = canvas.getBoundingClientRect();
  canvas.width = Math.round(rect.width * dpr);
  canvas.height = Math.round(rect.height * dpr);
}

function draw(i: number) {
  const hd = ready.get(i);
  const preview = previews[i];
  const src: CanvasImageSource | undefined = hd ?? (preview.complete && preview.naturalWidth ? preview : undefined);
  if (!src) return;
  const w = hd ? hd.width : preview.naturalWidth;
  const h = hd ? hd.height : preview.naturalHeight;
  // Cover-fit the frame to the canvas
  const scale = Math.max(canvas.width / w, canvas.height / h);
  const dw = w * scale;
  const dh = h * scale;
  ctx.drawImage(src, (canvas.width - dw) / 2, (canvas.height - dh) / 2, dw, dh);
}

let target = 0;
let drawn = -1;
let queued = false;

function tick() {
  queued = false;
  if (target === drawn) return;
  drawn = target;
  draw(target);
  updateWindow(target);
}

// Call from your scroll driver (ScrollTrigger onUpdate, Lenis, or a scroll listener)
function onProgress(progress: number) {
  target = Math.round(progress * (FRAME_COUNT - 1));
  if (!queued) {
    queued = true;
    requestAnimationFrame(tick);
  }
}

Scroll events can fire many times per screen refresh. onProgress only records the target frame, and tick draws at most once per animation frame, and only when the frame changed. Call sizeCanvas on load and on resize, then redraw. For wiring onProgress to ScrollTrigger, see the ScrollTrigger docs.

Respect reduced motion

Some readers set their device to reduce motion. For them, show a single still frame or poster image and skip the scroll-driven sequence. This is an accessibility requirement first, and it also saves those readers the full frame download.

frames.ts (continued)ts
const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;

if (!reduceMotion) {
  sizeCanvas();
  onProgress(0);
  // ...connect onProgress to your scroll driver here
}

In a real build, also gate the preview requests behind the same check, so nothing is fetched for a reader who will not see it. The prefers-reduced-motion reference lists the details, and reduced motion for scroll animation covers fallback design.

Measure with Lighthouse and PageSpeed Insights

Measure on mobile settings, not on your desktop connection. PageSpeed Insights runs Lighthouse with mobile emulation against your live URL, and Lighthouse in Chrome DevTools does the same locally. Watch three things:

  • Largest Contentful Paint: if it is late, frames are competing with the first paint. Defer the HD tier.
  • Total Blocking Time: long main-thread work, often from decoding or heavy scripts. Decode with createImageBitmap and trim script.
  • Total byte weight: compare it with your frame budget.

Lab scores do not capture memory pressure, so also scroll the page end to end on a real phone, fast and slow, and watch for tab reloads. The Web Vitals overview explains what each metric means. For the full build from idea to deploy, see the guide to building a 3D website with Claude, or start from the tuned frame pipelines in the Motion templates.

FAQ

Questions, answered.

The questions people ask most about this topic.

01Why does my scroll animation crash on iPhone?

Usually memory. Each decoded frame takes width × height × 4 bytes, so a 1920 × 1080 frame is about 8.3 MB once decoded. Holding hundreds of them makes iOS Safari reload or crash the tab. Keep only a window of HD frames near the scroll position and close the rest.

02How big should an image sequence be for mobile?

Set a budget first and divide by the frame count. As published examples, Kestra ships 443 frames in 26 MB and scores 90 on mobile, and Orbitly ships 691 frames in 16.59 MB and scores 72. Phones should also get a smaller portrait frame set.

03Should I preload every frame?

No. Load a light preview tier first, then stream HD frames nearest the scroll position. Preloading hundreds of HD frames delays the first paint and uses far more memory than a phone can spare.

04Does devicePixelRatio matter for canvas scroll animation?

Yes. The canvas is sized in device pixels, and phones often report a ratio of 3. Capping it at 2 cuts the canvas bitmap by more than half with little visible difference on moving footage.

05How do I test scroll animation performance on mobile?

Run PageSpeed Insights or Lighthouse with mobile settings and check Largest Contentful Paint, Total Blocking Time and total byte weight. Then scroll the page on a real phone, because lab tests do not show memory crashes.