Riff / Built on the open web / Platform

Dynamic import

Loads the Listen app only on the page that holds the block.

The Listen page: the library, nine albums as drawn record covers
This page has the Listen block, so the player imported the app that turns cover links into in-page navigation.

How Riff uses it

After the player is ready it checks for the Listen block and a module URL the feature put into the page data. Only then does it import() the app and call its start function with the public API. Posts without the block never download it.

Why

A static import would load the app on every post with audio.

Without it

A failed import leaves the server-rendered links as real links, so the library works as plain page loads.

Where

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

Reference: Dynamic import on MDN.