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

youtube-player

YouTube embed behind a facade: a thumbnail (or your own local poster) and one play button. The youtube-nocookie.com player loads only when the reader presses play.

Overview

A lightweight YouTube embed that uses the facade pattern: it renders a thumbnail and a play button on page load and defers the ~500 KB YouTube iframe until the reader presses play. The player loads from youtube-nocookie.com. The default thumbnail is fetched from i.ytimg.com on render; set a local poster to keep Google out of the page until play (see Privacy).

Light DOM only (no shadow root), so design tokens and utility classes apply naturally.

Default

Provide a YouTube video ID via video-id and the video's title via title. The play button is named "Play {title}". Without poster the thumbnail comes from i.ytimg.com.

Rounded

Apply the rounded class (inherited from the <video> native element vocabulary).

With Caption

Wrap in a <figure> with <figcaption> for a captioned embed.

Playlist

Pass a YouTube playlist ID via list. YouTube manages the playlist UI inside the iframe.

Local Poster

Set poster to a local image URL. The facade shows it instead of the YouTube thumbnail, so nothing is requested from Google until the reader presses play.

Start and End

Use start and end to play a clip, in whole seconds. Other formats (such as 1m30s) are ignored with a console warning; <social-embed> converts t=1m30s URLs to seconds for you.

Extra Player Parameters

params is an escape hatch for any other player parameter. Its keys override start, end, list and autoplay; the embed host cannot be changed.

Attributes

AttributeRequiredTypeDefaultDescription
video-idYesstring—YouTube video ID. A missing or invalid ID leaves the element un-upgraded, showing its authored fallback.
titleRecommendedstring"YouTube video"Video title: the iframe title and the {title} in the play button's name
poster—URL—Local facade image. When set, no thumbnail is requested from i.ytimg.com.
thumbnail—hq | mq | sd | maxreshqYouTube thumbnail size (ignored with poster). sd and maxres fall back to hq when the video has none.
start—integer—Start playback at N seconds
end—integer—Stop playback at N seconds
list—string—YouTube playlist ID
params—string—Extra query string for the embed URL (escape hatch)
autoplay—booleanfalseSkip the facade and load the iframe on connect. This contacts YouTube at once. Ignored under prefers-reduced-motion or data-motion-reduced; never moves focus.
data-label-play—string"Play {title}"Accessible name of the play button, for translation

Component-Managed Attributes

AttributeValuesDescription
stateready, activeFacade showing vs iframe inserted (read-only)

Events

EventDetailDescription
youtube-player:activate{ videoId, fromUser }Bubbles when the iframe is inserted. fromUser is false for autoplay.

Reconnect

Moving or re-inserting the element renders the facade again (state="ready"). A moved iframe reloads anyway and would restart playback, so the reader presses play again instead. With autoplay, the iframe is loaded again (still without taking focus).

CSS Classes

Inherited from the <video> native element vocabulary — no new classes invented.

ClassEffect
widescreen16:9 aspect ratio (default)
standard4:3 aspect ratio
ultrawide21:9 aspect ratio
roundedBorder radius via --radius-m token
fullinline-size: 100%

Progressive Enhancement

Author an <a> fallback inside the element. Without JavaScript, the link takes the user to YouTube. Once the component upgrades, the facade replaces the link.

ScenarioBehaviour
No JSAnchor link to YouTube visible
JS loadedFacade: thumbnail (or poster) + play button
Reader presses playIframe replaces facade, video autoplays, focus moves into the player
autoplayIframe rendered immediately, no facade step and no focus move (facade kept under reduced motion)

Privacy

What reaches Google, and when:

MomentWithout posterWith poster
Page load (facade)One image request to i.ytimg.com. It carries the reader's IP address but no referrer (referrerpolicy="no-referrer") and no cookies.Nothing
Reader presses playThe player loads from www.youtube-nocookie.com with referrerpolicy="strict-origin-when-cross-origin" (YouTube needs the origin). From here YouTube's own scripts run and may store data.
autoplayThe player loads on page load, with no facade step.

If your consent policy treats an image request to Google as tracking, always set poster. <social-embed> passes its own poster through to the player.

Accessibility

  • The inner <button> is the only control: one tab stop, named "Play {title}" (override with data-label-play). It covers the whole facade, so a click anywhere on the thumbnail plays.
  • The host has no role or tabindex, so there is no nested interactive control.
  • Thumbnail or poster image has alt="" (decorative; the button has the name)
  • Enter and Space activate the button natively
  • After the reader presses play, focus moves to the iframe. autoplay never moves focus.
  • Iframe has a descriptive title attribute
  • autoplay is ignored under prefers-reduced-motion; the hover scale uses the motion tokens, which drop to 0 ms under reduced motion
  • No-JS fallback is a plain anchor with meaningful text

Performance

MetricValue
JS size< 3 KB
CSS size< 1.5 KB
Network requests before play1 thumbnail from i.ytimg.com, or only your local poster
YouTube cookies before playNone

Related

  • <video-player> — Self-hosted video with custom overlay controls
  • <video> — Native video element (aspect-ratio classes shared with this component)
  • <iframe> — Native iframe element
  • poster — The native video attribute behind the poster facade
  • loading — Native lazy loading, which the facade replaces
  • sandbox — Lock down what an iframe may do
  • allow — Permissions Policy for iframes
↑