Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…

Read the release notes

poster

The image a video shows before playback starts. Pairs with preload=none for bandwidth savings; VB players and data-mock set it for you.

Overview

The poster attribute gives a video an image to show until playback starts. Without one, the browser shows the first frame once it has loaded, or an empty box if no video data has loaded yet (for example with preload="none").

A good poster tells people what the video is, makes it obvious that there is something to play, and stops the box flashing blank while the page loads.

Applies to: <video> only. <audio> has no poster.

Values

ValueMeaning
A URLShow this image before playback. Must be non-empty. Any image format the browser can decode works.
(absent, the default)Show the first frame once it is available, otherwise nothing.
Empty, or the image fails to loadTreated as no poster.

The poster shows until playback starts or the user seeks. After that the current frame stays on screen, even when paused.

Examples

Reserve the space

Give the video width and height attributes so the browser reserves the right box before the poster loads, and make the poster the same aspect ratio as the video. A poster with a different shape is letterboxed inside the box. VB makes every video fluid (max-inline-size: 100%; block-size: auto), so no inline style is needed.

With several <source> elements, poster still goes on the <video>.

Hero video and LCP

A poster above the fold can be the page's Largest Contentful Paint element. To start its download as early as possible, preload it at high priority:

Different posters per screen size

There is no srcset for posters: the browser loads the one URL. Make the poster the size of the largest box it fills and compress it well (AVIF or WebP), or swap it from script when your layout changes.

In Vanilla Breeze

  • Video defaults. src/native-elements/video/styles.css gives every video max-inline-size: 100%, block-size: auto, display: block and a dark background (--color-gray-900) that shows while the poster loads. The .widescreen, .standard and .ultrawide classes set an aspect ratio and letterbox with object-fit: contain; add .cover to crop instead.
  • <video-player> keeps the inner video's poster. In playlist mode, a track link's data-poster becomes the video's poster when that track is selected (src/web-components/video-player/logic.js).
  • <youtube-player poster> uses your local image for the facade instead of fetching the thumbnail from i.ytimg.com, so nothing is requested from Google until the user presses play.
  • data-mock on a <video> without a poster writes a placeholder SVG poster, labelled from alt or title (src/utils/mock-init.js).

Accessibility

  • A poster has no alt. Describe the video in nearby text: a heading, a <figcaption>, or the surrounding prose.
  • Do not put information only in the poster image. If it shows a title or a call to action, repeat that in HTML.
  • Do not bake a play button into the poster. Browsers and VB players draw their own, and the two end up stacked.

Gotchas

  • A heavy poster undoes the saving from preload="none". Compress it.
  • With autoplay, the poster may only flash, or not show at all, because playback starts straight away.
  • If the poster fails to load, you get the first frame (when video data has loaded) or an empty box.
  • The poster does not come back after playback has started. To show it again, reload the video (video.load()).

Related

  • preload — pair preload="none" with a poster.
  • controls — native controls versus VB players.
  • loading — lazy loading and fetchpriority for images.
  • <video> — element reference and VB video classes.

Which to choose

  • poster — any self-hosted video. Always set one when you use preload="none".
  • data-poster in <video-player> — a different poster per playlist track.
  • <youtube-player poster> — YouTube video without contacting Google before play.
  • data-mock — prototypes, before the real poster exists.
↑