How To Use Standard HTML Video & Audio Lazy-Loading on the Web Today
HTML <video> and <audio> elements now accept the same loading="lazy" attribute as images and iframes, deferring media, poster images and even autoplay until the element is visible near the viewport. Practical guidance covers setting width/height or aspect-ratio to avoid layout shift, pairing preload="none" with poster, keeping muted and playsinline for autoplay, and including controls on audio so it is visible enough to trigger loading. Avoid lazy loading above-the-fold media because it delays fetches until after layout and can hurt Largest Contentful Paint. Support can be detected with 'loading' in HTMLMediaElement.prototype; Chrome 148 ships it by default, and Squarespace-contributed Firefox and WebKit implementations are in review.
Related posts
- How we improved image download sizes on Medium with just four characters
Medium Engineering mediumAdeptAdding "auto" to the sizes attribute of lazy-loaded images lets the browser pick the best srcset candidate from the actual layout, with no hand-written breakpoint rules. Medium saw roughly 7% smaller image downloads on its home feed on some displays. The explanation covers why <picture>, srcset and sizes exist: browsers fetch images before layout, so sizes must otherwise be hand-calculated. Unsupported browsers ignore the unparseable "auto" token, so the change is backwards compatible, and WordPress has already adopted it.
- What the iPhone Duo means for web development
Mux mediumAdept
Safari on the foldable iPhone Duo exposes the Device Posture API and Viewport Segments API behind WebKit feature flags. They let pages detect a folded posture via `navigator.devicePosture` or `@media (device-posture: folded)` and position content per screen segment with `env(viewport-segment-*)` variables. Using these plus a flagged Fullscreen API, a Netflix-style folded video player was built from Video.js v10 components, with video on the top half and tiled controls on the bottom. A blurred, mirrored reflection is drawn by copying frames to a small canvas via requestVideoFrameCallback, since -webkit-box-reflect doesn't work on video in iOS Safari. In practice it needs three feature flags on iOS, and Chromium on a Pixel Fold clips fullscreen content to the top half, so the design isn't shippable today.
- WebKit Features in Safari 17.1
WebKit easyNoviceSafari 17.1 brings the Managed Media Source API to iPhone, a power-efficient alternative to Media Source Extensions for adaptive bitrate streaming. It hands more buffer and network management to the browser and requires an AirPlay source alternative or explicitly disabled remote playback. The release also adds storage.session.setAccessLevel for Safari extensions, with storage.session restricted to trusted contexts by default. Bug fixes cover accessibility, CSS, RegExp look-behind, HLS and MediaSource playback, IntersectionObserver performance, popovers in shadow DOM and WebGL context loss.
- How to use Media Source Extensions with AirPlay
WebKit mediumAdeptMedia Source Extensions and Apple's Managed Media Source can't be used with AirPlay because they feed binary blobs into a SourceBuffer, and AirPlay needs a real playback URL. The workaround is to give the video element multiple <source> children. Put the object URL created from the MediaSource first and an AirPlay-compatible HLS URL second. Safari then shows the AirPlay button and switches to the HLS source when the user casts. The example code feature-detects ManagedMediaSource with a fallback to MediaSource, and it uses the startstreaming event to load segments when that event is available.
- Looking fine with Firefox 89
Mozilla Hacks mediumAdeptFirefox 89 ships a slimmer, more minimalist interface alongside several new web platform features. The `forced-colors` media query detects modes like Windows High Contrast, for example to swap a suppressed `box-shadow` for a border. The `ascent-override`, `descent-override` and `line-gap-override` @font-face descriptors let local fallback fonts match web font metrics and reduce layout shift. The release also enables top-level `await` in JavaScript modules, so parent modules wait for child modules without blocking sibling loading, and adds the `PerformanceEventTiming` API for timing user-triggered events.