Skip to main content

Display

markPicturesReady

Marks pictures the app has already loaded and decoded as ready, so an Avatar with the same src draws the picture on its first frame instead of its initials. An image that is not loaded, or failed, is skipped. Give it images whose src attribute is the exact string you pass Avatar as src.

import { markPicturesReady } from "@/lib/ouro/avatar-pictures";

Example

const image = new Image();
image.src = "/people/ana.jpg";
await image.decode();
markPicturesReady([image]);
// <Avatar name="Ana Lind" src="/people/ana.jpg" /> now draws the picture on its first frame.

Usage

Use it after warming pictures ahead of time, such as in a list's preload. Without it, an avatar whose picture the browser holds may still draw its initials first.

Parameters

images
Type: Iterable<HTMLImageElement>

Returns

void