Using 'nocookie' youtube api. Is this valid?

Is this a valid javiscript code?

This code here: Added
host: 'https://www.youtube-nocookie.com',

Removed:
host: 'https://www.youtube-nocookie.com',

https://i.imgur.com/s2VpGxE.png


<div id="player"  class='video-frame' ></div>

<script>
  var tag = document.createElement('script');
  tag.src = "https://www.youtube.com/player_api";
  var firstScriptTag = document.getElementsByTagName('script')[0];
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

  var player;

  function onYouTubePlayerAPIReady() {
    player = new YT.Player('player', {
      height: '315',
      width: '560',
      host: 'https://www.youtube-nocookie.com',
      videoId: 'bHQqvYy5KYo',
      playerVars: {
        autoplay: 0,
        loop: 0,
        controls: 1,
        showinfo: 1,
        autohide: 0,
        rel: 0,
        iv_load_policy: 3,
        cc_load_policy: 0,
        fs: 0,
        disablekb: 1,
        end: 281,
      },

      events: {
        'onReady': onPlayerReady
      }
    });
  }

  function onPlayerReady(event) {
    event.target.setVolume(100);
    event.target.stopVideo();

  }

</script>

Can you answer this for me? @Paul_Wilkins

Does inspect element tell you anything?

Is this valid?

  host: 'https://www.youtube-nocookie.com',

 window.onYouTubePlayerAPIReady = function() {
    new YT.Player(document.querySelector(".js-player"), {
      height: '315',
      width: '560',
      host: 'https://www.youtube-nocookie.com',
      videoId: 'M7lc1UVf-VE',

It shows someone using it here:

Yes, it seems to work.

1 Like

I was wondering because I couldn’t find any documentation on it at all.

I found someone talking about it here: It’s towards the bottom.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.