Skip to content
TopicTracker
From simonwillison.netView original
TranslationTranslation

<click-to-play> — a still that plays

Simon Willison introduces a progressive enhancement Web Component called &lt;click-to-play&gt; that transforms a linked GIF into a still image with a play button, loading the GIF only when the user clicks. This avoids loading large GIFs until the user chooses to play them.

Background

Simon Willison is an influential web developer, creator of the Datasette open-source tool for exploring data, and a long-time advocate of progressive enhancement (a design philosophy that web features should work on a baseline level even without JavaScript, then be improved for capable browsers). This post introduces a tiny custom HTML element he built called `<click-to-play>` — a "Web Component" (a reusable piece of self-contained UI code using browser-native standards). The problem it solves: animated GIFs are large and slow to load. Instead of forcing every visitor to download the GIF upfront, the component shows a static placeholder image (the first frame) and only loads the actual animated GIF when the user clicks a play button. He specifically created it for a blog post about Datasette's new row editing tools, where he wanted to show an animated demo without slowing down the page for everyone.

Related stories

  • HtmlUnit 5.0.0 has been released, now requiring JDK 17 as the minimum version. Key updates include major JavaScript engine improvements, full Web Crypto API support, WebSocket improvements, Web Speech API support, and updated browser profiles for Firefox 150 and Chrome/Edge 148.

  • JsPlumb, the JavaScript library for building visual connectivity interfaces, has released a major update with a modernized API and new diagram/2D chart engines. The project is now free for non-commercial use, with packages available for React, Angular, Vue, Svelte, and vanilla JS on the public NPM registry.

  • Datasette-apps is a new system that allows users to bundle and install full applications within Datasette, turning it into a platform for data-driven apps. It enables developers to create self-contained packages combining SQLite databases, metadata, plugins, templates, and assets.