class GifLike extends HTMLElement { static motionQuery = window.matchMedia( “(prefers-reduced-motion: no-preference)” ); connectedCallback() { this.video = this.querySelector(“video”); GifLike.motionQuery.addEventListener(“change”, (query) => { this.toggle(query.matches); }); this.toggle(GifLike.motionQuery.matches); } toggle(state) { if (state) { this.video.play(); } else { this.video.pause(); } } } customElements.define(“gif-like”, GifLike);