finds.dev← search

// the find

toddmotto/fluidvids

★ 415 · JavaScript · NOASSERTION · updated Aug 2022

Fluid width (responsive) videos module, 1KB, custom players, dynamic elements/XHR support.

A 1KB JavaScript module that wraps iframe embeds in an intrinsic-ratio container so YouTube/Vimeo videos scale responsively. Solves a real problem that predates native CSS solutions. Last touched in 2022, and the problem it solved is now mostly handled by `aspect-ratio: 16/9` in CSS.

Tiny and self-contained — no dependencies, one init call and you're done. The `render()` method for dynamically injected iframes is a thoughtful addition that most CSS-only approaches miss. Domain whitelist via regex means it won't accidentally wrap every iframe on a page. Jasmine test suite exists and covers the main logic.

The CSS `aspect-ratio` property is now baseline-available across all modern browsers, which makes this library unnecessary for any project not targeting IE. Last commit was 2022 and the repo shows no signs of life — you'd be adopting abandoned code. The `require('fluidvids.js')()` module pattern (called as a function) is an odd API that will confuse anyone used to standard ESM or CJS. Bower installation instructions are still in the README, which dates it badly.

View on GitHub → Homepage ↗

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →