Guide · Web performance

The iOS Safari 60fps limit: making web apps feel native

I always hated that the web apps I coded didn't feel like native apps. The layout could be perfect and the code fast, and something was still off the moment you dragged it with a finger. A big part of it was a limit I couldn't code around: on iPhone, Safari updates web pages at 60fps, even on a 120Hz screen.

A limit only web developers have

If you build native, a ProMotion iPhone gives you up to 120 frames a second. If you're strictly a web developer, you get half, on the same phone and the same screen. You can remove frameworks, shrink bundles and optimise every function, and you still hit the same wall. That's what made it a pain: it wasn't my code, so I couldn't fix it.

Frames in 100 milliseconds at 60fps and 120HzIn 100 milliseconds a 60fps page shows 6 frames, one every 16.7 ms. A 120Hz screen can show 12, one every 8.3 ms.Safari page: 60fpsevery 16.7 msScreen: 120Hzevery 8.3 ms
The same 100 milliseconds. The screen can show 12 frames, but the page gets 6.

WebKit has two reasons: higher frame rates use more power, and some pages misbehave when their callbacks run faster than 60 times a second. Fair reasons, but the choice isn't left to the developer. There is a Safari setting, “Prefer Page Rendering Updates near 60fps”, but you can't ask your users to dig through feature flags.

What changed

Then I read Rida F'kih's Bypassing iOS Safari’s 60 FPS Limit. It shows a way around the limit with standard web APIs. This article is a follow-up: the same idea in simpler terms, with code you can copy. The discovery and every measurement mentioned here are Rida's, so read the original for live demos and for how it was found.

Rida's recording of an iPhone 18 Pro averaged 118fps during a drag, against 60fps with normal pointer events.

The idea in simple terms

There are two limits, and you need to get past both:

The limitThe way around
OutputWhat the page draws appears at 60fpsDraw on an OffscreenCanvas in a worker
InputTouch events on a normal page arrive at 60HzPut an invisible scrolling area under the finger

Think of the page as a bus that leaves 60 times a second. Everything you change in the DOM waits for the next bus. A canvas handed to a worker doesn't: in WebKit its frames can be shown without waiting for the page.

Scrolling was never on that bus. Safari moves scrolled content outside your JavaScript, which is why scrolling feels native on even a slow website. So we let the finger scroll something invisible, and use that movement for our own interface.

Step 1: the HTML and CSS

A canvas to draw on, and a scrolling area on top of it. The inner element is much larger than the area, so it can scroll in every direction:

HTML
<div class="demo">
  <canvas id="stage" aria-hidden="true"></canvas>
  <div id="controller" tabindex="0" role="group"
       aria-label="Move the square: drag it or use the arrow keys">
    <div class="surface"></div>
  </div>
</div>
CSS
.demo { position: relative; height: 320px; }
#stage { width: 100%; height: 100%; }

#controller {
  position: absolute;
  inset: 0;
  overflow: scroll;
  overscroll-behavior: contain; /* don't scroll the page */
  scrollbar-width: none;
}
#controller::-webkit-scrollbar { display: none; }
.surface { width: 4000px; height: 4000px; }

Step 2: draw outside the page

transferControlToOffscreen() hands the canvas to a worker. From then on, the page only sends small messages:

JavaScript · main.js
const canvas = document.querySelector("#stage");
const { width, height } = canvas.getBoundingClientRect();
const scale = window.devicePixelRatio || 1;
canvas.width = Math.round(width * scale);
canvas.height = Math.round(height * scale);

const worker = new Worker("/worker.js");
const offscreen = canvas.transferControlToOffscreen();
worker.postMessage({ type: "init", canvas: offscreen, width, height, scale }, [offscreen]);

const move = (dx, dy) => worker.postMessage({ type: "move", dx, dy });

The worker keeps the position and draws as soon as a message arrives. There's no requestAnimationFrame here, because we don't want to wait for a callback that may be limited to 60fps:

JavaScript · worker.js
let ctx, width, height;
let x = 40;
let y = 40;
const SIZE = 72;

function draw() {
  ctx.clearRect(0, 0, width, height);
  ctx.fillStyle = "#1a8fe3";
  ctx.fillRect(x, y, SIZE, SIZE);
}

self.onmessage = ({ data }) => {
  if (data.type === "init") {
    ({ width, height } = data);
    ctx = data.canvas.getContext("2d");
    ctx.scale(data.scale, data.scale);
  } else {
    // move, but stay inside the canvas
    x = Math.max(0, Math.min(width - SIZE, x + data.dx));
    y = Math.max(0, Math.min(height - SIZE, y + data.dy));
  }
  draw(); // new input arrived: draw now, don't wait for a frame callback
};

Step 3: read the finger faster

On iPhone, a passive touchmove listener on a scrolling area fires at the full 120Hz, according to Rida's tests. Passive means we promise not to block the scroll, so Safari doesn't have to wait for us:

JavaScript · main.js, continued
const pad = document.querySelector("#controller");
const iosTouch = "GestureEvent" in window && navigator.maxTouchPoints > 0;
let last = null;

const track = (point) => {
  if (last) move(point.clientX - last.x, point.clientY - last.y);
  last = { x: point.clientX, y: point.clientY };
};
const stop = () => { last = null; };

if (iosTouch) {
  const passive = { passive: true };
  const centre = () => pad.scrollTo(pad.scrollWidth / 2, pad.scrollHeight / 2);
  centre();
  pad.addEventListener("touchstart", (e) => { centre(); stop(); track(e.touches[0]); }, passive);
  pad.addEventListener("touchmove", (e) => track(e.touches[0]), passive);
  pad.addEventListener("touchend", stop, passive);
  pad.addEventListener("touchcancel", stop, passive);
} else {
  // other browsers: normal pointer events are fine
  pad.style.touchAction = "none";
  pad.style.overflow = "hidden";
  pad.addEventListener("pointerdown", (e) => { pad.setPointerCapture(e.pointerId); stop(); track(e); });
  pad.addEventListener("pointermove", (e) => { if (last) track(e); });
  pad.addEventListener("pointerup", stop);
  pad.addEventListener("pointercancel", stop);
}

// dragging can't be the only way to use it
const arrows = { ArrowLeft: [-10, 0], ArrowRight: [10, 0], ArrowUp: [0, -10], ArrowDown: [0, 10] };
pad.addEventListener("keydown", (e) => {
  if (!arrows[e.key]) return;
  e.preventDefault();
  move(...arrows[e.key]);
});

We ignore how far the area scrolled and use only how far the finger moved. The other browsers get normal pointer events, and the arrow keys work everywhere.

Optional: native momentum

The version above stops when the finger lifts. Native apps keep moving and slow down. Writing that physics yourself never feels quite right, but the invisible area already has it. You only have to read its scroll position often enough.

Scroll events are too slow: Rida measured 5 to 26 a second during momentum. This simplified version of the approach reads the position about 120 times a second, and stops when nothing moves:

JavaScript · momentum.js
function watchScroll(scroller, onMove) {
  const STEP = 1000 / 120;
  const IDLE_MS = 200;
  const { port1, port2 } = new MessageChannel();
  let running = false;
  let vsync = 0;
  let changedAt = 0;
  let left = scroller.scrollLeft;
  let top = scroller.scrollTop;

  // keeps Safari sending positions, and tells us when frames start
  const frame = (time) => {
    vsync = time;
    if (running) requestAnimationFrame(frame);
  };

  const read = () => {
    const now = performance.now();
    const dx = scroller.scrollLeft - left;
    const dy = scroller.scrollTop - top;
    if (dx || dy) {
      left += dx;
      top += dy;
      changedAt = now;
      onMove(-dx, -dy); // content scrolls the opposite way to its offset
    }
    if (now - changedAt > IDLE_MS) running = false; // stop, save battery
    else port2.postMessage(null);
  };

  port1.onmessage = () => {
    const now = performance.now();
    const next = vsync + (Math.floor((now - vsync) / STEP) + 1) * STEP;
    setTimeout(read, next - now);
  };

  const wake = () => {
    changedAt = performance.now();
    if (running) return;
    running = true;
    vsync = changedAt;
    requestAnimationFrame(frame);
    read();
  };

  scroller.addEventListener("touchstart", wake, { passive: true });
  scroller.addEventListener("scroll", wake, { passive: true });
}
JavaScript
// use this instead of the touch listeners from step 3
watchScroll(pad, move);

Reading 120 times a second doesn't mean getting 120 new positions. In Rida's tests, a loop like this reached about 90. Getting to 120 took a GPU-accelerated CSS animation plus a tiny hidden scroller to push the screen to its full rate, and the original article explains why. A real version also has to recentre the area before it reaches an edge.

When I would use it

  • Good fit: drawing tools, games, maps, sliders, dials, and one or two gestures people use all day.
  • Not needed: normal scrolling, and simple movement that CSS animations already handle.
  • Bad fit: a whole app. Text in a canvas isn't selectable, searchable or readable by a screen reader unless you build that separately.
  • Draw only when something changes. More frames use more battery, so nothing should run while the screen is idle.
  • Keep a plain version. If transferControlToOffscreen is missing, fall back to a normal canvas or to the DOM.
  • Expect it to change. It depends on how WebKit works today, and Apple could make those frames wait for the page again. Rida wouldn't rebuild a whole application around it, and neither would I.

Treat the code as a starting point and test it on real ProMotion devices. Low Power Mode and Limit Frame Rate (Settings, Accessibility, Motion) both lower the frame rate, and the iOS simulator won't show you 120Hz.

Will the web ever feel native?

I don't think frame rate is the only difference, but it's the one you feel without knowing why. For years the answer was “build a native app”. Now a small part of the interface, the part under the finger, can run at the speed of the screen, with nothing but web code. The best outcome would be for Apple to lift the limit and make this article useless.

FAQ

Why is Safari limited to 60fps on iPhone?

WebKit limits page updates to about 60 per second to save power and because some pages misbehave when animation callbacks run faster. The limit applies even on 120Hz ProMotion screens.

Can a web app run at 120fps on iOS?

Parts of it can. Scrolling isn't held to the page's 60fps, and a canvas drawn by a worker through OffscreenCanvas can be shown faster than the page. Normal DOM updates and requestAnimationFrame on the page stay at about 60.

Does requestAnimationFrame run at 120Hz in Safari on iPhone?

Not by default. It runs at about 60 per second unless the user turns off the Prefer Page Rendering Updates near 60fps flag in Safari's settings.

Does OffscreenCanvas bypass the 60fps limit?

In current WebKit on iOS, yes, according to Rida F'kih's tests. Frames from an OffscreenCanvas don't wait for the page's next rendering update. It isn't a guaranteed behaviour, so a future Safari version could change it.

Is it safe to use in production?

Use it as an enhancement for one interaction, with a fallback, keyboard access and testing on real devices. Don't make the whole app depend on it.