demo · v144

Extension Recipes

Four real reasons authors call waitUntil(): hold the pseudo-tree through an image decode, through a fetch, through a Lottie/Web Animations sequence, or through a network handshake. Each recipe fires a transition and shows the timing — with and without the wait.

document.startViewTransition: checking…

the API

const t = document.startViewTransition(() => updateDOM());

// recipe 1: hold for image decode
t.ready.then(() => {
  t.waitUntil(image.decode());
});

// recipe 4: timeout race
t.waitUntil(Promise.race([
  loadHero(),
  new Promise((r) => setTimeout(r, 800))
]));

see also