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…
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.
Minimal usage
1234
<youtube-playervideo-id="dQw4w9WgXcQ"title="Rick Astley — Never Gonna Give You Up"></youtube-player>
Rounded
Apply the rounded class (inherited from the <video> native element vocabulary).
Rounded variant
123456
<youtube-playerclass="rounded"poster="/src/assets/placeholders/photo-kitchen-sink-13-640x360.svg"video-id="dQw4w9WgXcQ"title="Rick Astley — Never Gonna Give You Up"></youtube-player>
With Caption
Wrap in a <figure> with <figcaption> for a captioned embed.
Captioned embed
123456789
<figure><youtube-playerclass="rounded"poster="/src/assets/placeholders/photo-kitchen-sink-13-640x360.svg"video-id="dQw4w9WgXcQ"title="Rick Astley — Never Gonna Give You Up"></youtube-player><figcaption>Never Gonna Give You Up — Rick Astley (1987)</figcaption></figure>
Playlist
Pass a YouTube playlist ID via list. YouTube manages the playlist UI inside the iframe.
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.
Local poster
12345
<youtube-playerposter="/src/assets/placeholders/photo-kitchen-sink-13-640x360.svg"video-id="dQw4w9WgXcQ"title="Rick Astley — Never Gonna Give You Up"></youtube-player>
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.
Play 0:30 to 1:00
1234567
<youtube-playerposter="/src/assets/placeholders/photo-kitchen-sink-13-640x360.svg"video-id="dQw4w9WgXcQ"start="30"end="60"title="Rick Astley — 0:30 to 1:00"></youtube-player>
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.
Captions on by default
12345
<youtube-playervideo-id="dQw4w9WgXcQ"params="cc_load_policy=1"title="Rick Astley — Never Gonna Give You Up"></youtube-player>
YouTube video ID. A missing or invalid ID leaves the element un-upgraded, showing its authored fallback.
title
Recommended
string
"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 | maxres
hq
YouTube 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
—
boolean
false
Skip 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
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.
Class
Effect
widescreen
16:9 aspect ratio (default)
standard
4:3 aspect ratio
ultrawide
21:9 aspect ratio
rounded
Border radius via --radius-m token
full
inline-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.
No-JS fallback
123456789
<!-- Without JS: renders as a plain link to YouTube --><youtube-playerposter="/src/assets/placeholders/photo-kitchen-sink-13-640x360.svg"video-id="dQw4w9WgXcQ"title="Rick Astley — Never Gonna Give You Up"><ahref="https://youtu.be/dQw4w9WgXcQ"> Watch on YouTube: Rick Astley — Never Gonna Give You Up</a></youtube-player>
Scenario
Behaviour
No JS
Anchor link to YouTube visible
JS loaded
Facade: thumbnail (or poster) + play button
Reader presses play
Iframe replaces facade, video autoplays, focus moves into the player
autoplay
Iframe rendered immediately, no facade step and no focus move (facade kept under reduced motion)
Privacy
What reaches Google, and when:
Moment
Without poster
With 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 play
The 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.
autoplay
The 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.