title: YouTube Iframe API Embed with No Ads on Video
body: <p>In my project, I am using YouTube video embeds (not my videos) and I want them to not display ads.</p>
  <p>When I use Iframe embed (without Iframe API - with youtube-nocookie.com), it works, ads are not displayed, which I want.</p>
  <pre><code>&lt;iframe id=&quot;video&quot; src=&quot;https://www.youtube-nocookie.com/embed/7TXKBlBBbIA?fs=0&amp;modestbranding=1&amp;playsinline=1&amp;rel=0&quot; allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture&quot; width=&quot;640&quot; height=&quot;360&quot; frameborder=&quot;0&quot;&gt;&lt;/iframe&gt;
  </code></pre>
  <p>But when I use Iframe API (with youtube-nocookie.com), ads are displayed, which I don't want.</p>
  <p><a href="https://developers.google.com/youtube/iframe_api_reference" rel="nofollow noreferrer">https://developers.google.com/youtube/iframe_api_reference</a></p>
  <pre><code>// HTML
  &lt;div id=&quot;video&quot;&gt;&lt;/div&gt;
  
  // JS
  var tag = document.createElement('script');
  tag.src = 'https://www.youtube.com/iframe_api';
  var firstScriptTag = document.getElementsByTagName('script')[0];
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
  
  function onYouTubeIframeAPIReady() {
      video = new YT.Player('video', {
          height: 360,
          width: 640,
          videoId: '7TXKBlBBbIA',
          host: 'https://www.youtube-nocookie.com',
          playerVars: {
              'fs': 0,
              'modestbranding': 1,
              'playsinline': 1,
              'rel': 0
          }
      });
  }
  </code></pre>
  <p>The thing is, I need to use the Iframe API, but not display ads. Any way to achieve that?</p>
  <p>It seems <code>https://listenonrepeat.com/</code> does it, but I couldn't figure out how they do it.</p>