Riff / Built on the open web / Media

Async decoding

Decodes cover art off the main thread so the seek line does not stutter.

Now Playing on a phone: the cover, the title and artist, a seek bar, and the play controls
The large cover decodes off the main thread when the track changes.

How Riff uses it

Every image the player prints carries decoding="async": the large cover and the two thumbnails in the template, each row and queue item, and each library card. The off-screen image loaded to sample a cover's colour sets it too.

Why

The cover swaps on every track change while the seek line is animating each frame, and a synchronous decode would drop a frame.

Without it

Browsers without the hint decode as usual.

Where

Links open the source at the commit this page was published from.

Reference: Async decoding on MDN.