Embedding YouTube videos without the initial IFRAME loading speeds up the page load, and enables the “Privacy Enhanced” method of embed. The IFRAME and html5 player from YT is loaded when the user clicks the thumbnail.
YouTube will drop 37 cookies when a visitor view a standard embedded YouTube video…
Add the CSS classes to main.css or any stylesheet loaded by your theme in assets/css
Add the button displayed on the poster image to assets/images in your theme folder.
Transparent PNG 179x179 yt-play-square.png12.7 KB file on MEGA
Here’s the PSD 65.9 KB file on MEGA
To embed a YouTube video insert a HTML card in the post with the video ID, ex <div class="youtube-player" data-id="sXiRZhDEo8A"></div>
The button is referenced as background-image in the CSS so if you move it update… background: url('../images/yt-play-square.png') no-repeat;
I modified the CSS to use aspect-ratio and made the placement of the play-button responsive by using transform: translate(-50%, -50%); Tested on mobile and desktop, it seems to work.
I looked into this some. youtube-nocookie.com is also owned by Google. It tracks using local storage instead of setting a cookie before the video starts playing, and according to this article also sets a cookie after the video starts playing, despite the name. Because no consent is collected for the tracking, it’s possible even the “no cookie” way embedding YouTube videos is also illegal in the EU unless careful steps are taken to collect consent for first.
Tested it in dev console on Edge and it does save yt-remote-device-id in local storage which is both disturbing and annoying. With GDPR’s focus on PII Personally Identifiable Information I’m wondering if they are able to triangulate the yt-remote-device-id against a Google User ID.
Verified that the remote-device-id is the same across different videos embedded from youtube-nocookie.com. This way they can track videos watched by an anonymous user on one device, but they are also sending the full URL of page where the video is embedded…
Technically they are not storing a cookie, but they are storing device-id in local storage. Sneaky bastards. I’m using EFF Disconnect on Chrome so I didn’t see this at first, it blocks local storage, but this happens on Edge without the Disconnect-plugin.