Agent Wranglers

WEB-219Required EU law

Load embedded videos and maps only after a click

Load no third-party embed, such as a video, map or social post, before the visitor clicks it or has consented. Show a still image and a button in its place.

Region

European Union (EU). The duty comes from the law there. The rule applies only when the project serves people there, and its Applies when also holds.

How to do it

Embeds from video, map and social sites set cookies and send the visitor's IP address before anyone presses play. Show a local thumbnail, a short note naming the provider and a link to its privacy policy. On click, swap in the iframe. Use the provider's no-cookie address where one exists, such as youtube-nocookie.com. Give every page a plain link to the content too, so it works without JavaScript. Hosting the video yourself avoids the question.

Examples

HTML example

<div class="video" data-src="https://www.youtube-nocookie.com/embed/abc123?autoplay=1">
  <img src="/img/tour-poster.webp" alt="Tour of the Example Studio workshop" width="640" height="360">
  <button type="button">Play video from YouTube</button>
  <p>Playing loads YouTube, which may set cookies. <a href="https://www.youtube.com/watch?v=abc123">Watch on YouTube</a>.</p>
</div>
<script type="module">
  for (const box of document.querySelectorAll('.video')) {
    box.querySelector('button').addEventListener('click', () => {
      const frame = document.createElement('iframe');
      frame.src = box.dataset.src;
      frame.title = box.querySelector('img').alt;
      frame.allow = 'autoplay; fullscreen';
      box.replaceChildren(frame);
    }, { once: true });
  }
</script>

How to check

With a fresh browser profile, load each page with an embed. No request goes to the provider until the button is clicked.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/website/privacy/click-to-load-embeds">Agent Wranglers website playbook</a>. In code you write, add a comment next to it with the same link.