Skip to content

Serve YouTube embeds from youtube-nocookie.com and Vimeo with dnt=1 - #23

Merged
davidperezgar merged 2 commits into
mainfrom
fix/youtube-nocookie
Nov 11, 2026
Merged

davidperezgar merged 2 commits into
mainfrom
fix/youtube-nocookie

Conversation

@amulero

@amulero amulero commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Problem

Embedded YouTube videos loaded from youtube.com as soon as the page opened, so YouTube set cookies before the visitor had accepted or rejected anything.

Solution

FrontConsent now rewrites video embeds before the page is sent to the visitor:

  • YouTube: youtube.com/embed/… → youtube-nocookie.com/embed/… (YouTube's privacy-enhanced mode, no cookies on load).
  • Vimeo: adds dnt=1 (do not track) to player.vimeo.com/video/….

Editors keep pasting normal YouTube/Vimeo links; nothing changes in the content. Videos are still visible and playable, they just don't set cookies before consent. Lazy-loaded videos (e.g. WP Rocket) are covered too.

Only active while the Cookie Notice is enabled. Can be turned off with the frcn_privacy_enhanced_embeds filter.

Tests

New PrivacyEmbedsTest. PHPUnit, JS tests, phpcs and phpstan pass.

Version: 1.0.3-beta.youtube.

amulero and others added 2 commits November 6, 2026 12:36
tuwebcumple.es flagged "YouTube videos set cookies before consent".
Editors paste normal YouTube/Vimeo links and WordPress stores the regular
embed URL; the new PrivacyEmbeds class rewrites those iframes on output
(src and lazy-load copies such as WP Rocket's data-lazy-src) to the
cookieless modes, so videos stay visible but set no cookies before the
visitor decides.

Only active while the Cookie Notice is enabled; filter
frcn_privacy_enhanced_embeds turns it off. Version 1.0.3-beta.youtube.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The version bump and changelog entry are done once on main when 1.0.3 is
released, so the open PRs do not conflict with each other.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@davidperezgar
davidperezgar merged commit 8c485d5 into main Nov 11, 2026
6 checks passed
@davidperezgar
davidperezgar deleted the fix/youtube-nocookie branch November 11, 2026 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants