Embed Youtube Iframe on Website with Video Loop

Embedding YouTube videos on your website is a common practice, but sometimes you may want the video to loop continuously. Fortunately, YouTube provides an easy way to set up looping for embedded videos.


Basic Embed Code

Start with the basic YouTube embed code (without loop). For example:

1
2
3
4
5
<iframe src="https://www.youtube.com/embed/1O0yazhqaxs"
        width="560"
        height="315"
        title="3 Second Video"
        frameborder="0"></iframe>

Step 1: add Required “loop” Parameter

To enable looping, you need to add loop=1 to the URL parameters.


Step 2: add Required “playlist” Parameter

You also need to include the playlist parameter with the video ID to ensure the video loops. The playlist parameter should have the same video ID as the video you want to loop.


Complete Embed Code

Combine these parameters to create the final embed code. Here’s the complete code to loop the YouTube video:

1
2
3
4
5
<iframe src="https://www.youtube.com/embed/1O0yazhqaxs?loop=1&fs=0&playlist=1O0yazhqaxs"
        width="560"
        height="315"
        title="3 Second Video"
        frameborder="0"></iframe>

Example: https://jsfiddle.net/x4z73rjL/


Example Breakdown

  • Video ID: 1O0yazhqaxs
  • Loop Parameter: loop=1 (enables looping)
  • Playlist Parameter: playlist=1O0yazhqaxs (repeats the same video)

Final Embedded Video

Here is the full example of an embedded YouTube video that loops continuously:

1
2
3
4
5
<iframe src="https://www.youtube.com/embed/1O0yazhqaxs?loop=1&fs=0&playlist=1O0yazhqaxs"
        width="560"
        height="315"
        title="3 Second Video"
        frameborder="0"></iframe>

Example: https://jsfiddle.net/x4z73rjL/

This will embed the YouTube video on your webpage, and it will loop automatically once it reaches the end.


Additional Tips

  • Autoplay: If you want the video to start playing automatically when the page loads, you can add the autoplay=1 parameter to the URL.
    1
      <iframe src="https://www.youtube.com/embed/1O0yazhqaxs?loop=1&fs=0&playlist=1O0yazhqaxs&autoplay=1" width="560" height="315" title="3 Second Video" frameborder="0"></iframe>
  • Remove Controls: To hide the player controls, add controls=0 to the URL parameters.
    1
      <iframe src="https://www.youtube.com/embed/1O0yazhqaxs?loop=1&fs=0&playlist=1O0yazhqaxs&controls=0" width="560" height="315" title="3 Second Video" frameborder="0"></iframe>

By following these steps, you can easily loop embedded YouTube videos on your website, providing a seamless viewing experience for your audience.


Hello, I am an enthusiastic Adobe Community Advisor and a seasoned Lead AEM Developer. I am currently serving as an AEM Technical Lead at MNPDigital.ca, bringing over a decade of extensive web engineering experience and more than eight years of practical AEM experience to the table. My goal is to give back to the AEM Full Stack Development community by sharing my wealth of knowledge with others. You can connect with me on LinkedIn.

Leave a Reply

Your email address will not be published. Required fields are marked *