Riff / Built on the open web / Platform

pageshow

Restarts the frame loop after a Back from the back-forward cache.

Now Playing on a phone: the cover, the title and artist, a seek bar, and the play controls
After a Back from the cache the seek line here would be frozen without the restart.

How Riff uses it

When a page is restored from the back-forward cache, pageshow fires with persisted set. The handler repaints the seek line and, if the media element is still playing, restarts the per-frame loop the browser stopped when it froze the page.

Why

The audio element kept its state in the cache but the animation loop did not, so the music would be playing while the seek line sat still.

Without it

persisted is checked, so a normal load does nothing.

Where

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

Reference: pageshow on MDN.