How to Autoplay Embedded YouTube Videos
Key takeaways
Add autoplay=1&mute=1 to the embed URL — browsers only allow muted autoplay reliably.
Add playsinline=1 for iPhone and allow="autoplay" on the iframe.
Loop a single video with loop=1&playlist=VIDEO_ID.
Start autoplay only when the video is visible or when a popup opens.
The autoplay embed code
<iframe src="https://www.youtube.com/embed/VIDEO_ID?autoplay=1&mute=1&playsinline=1"
title="YouTube video" allow="autoplay; encrypted-media; picture-in-picture"
allowfullscreen></iframe>Or generate it with our YouTube embed code generator — turn on Autoplay.
Autoplay and loop
To loop, add loop=1&playlist=VIDEO_ID — YouTube loops a single video only when the playlist parameter repeats its ID.
Why YouTube autoplay doesn’t work
mute=1is missing.The iframe lacks
allow="autoplay".The video owner disabled embedding.
On iPhone,
playsinline=1is missing.
Autoplay in a gallery
YouTube player parameters for autoplay and playback
autoplay
Value
What it does
mute
Value
What it does
loop
Value
What it does
playlist
Value
What it does
playsinline
Value
What it does
controls
Value
What it does
start / end
Value
What it does
rel
Value
What it does
Full list: YouTube embedded player parameters.
Autoplay only when the video scrolls into view
Autoplaying a video far down the page wastes bandwidth. Use the IFrame API and an IntersectionObserver to start it only when visible:
<div id="yt"></div>
<script src="https://www.youtube.com/iframe_api"></script>
<script>
let player;
function onYouTubeIframeAPIReady() {
player = new YT.Player("yt", {
videoId: "VIDEO_ID",
playerVars: { mute: 1, playsinline: 1, rel: 0 }
});
new IntersectionObserver(([e]) => {
if (!player.playVideo) return;
e.isIntersecting ? player.playVideo() : player.pauseVideo();
}, { threshold: 0.5 }).observe(document.getElementById("yt"));
}
</script>Autoplay YouTube in WordPress, Shopify, Wix and Squarespace
WordPress: the Embed block doesn’t expose autoplay — paste an iframe with autoplay=1&mute=1 into a Custom HTML block.
Shopify: add the iframe to a Custom Liquid section.
Wix: use Embed HTML with the iframe code.
Squarespace: use a Code block with the iframe.
Our YouTube embed code generator builds the iframe with the right parameters.
Troubleshooting checklist
Is it muted?
Without mute=1 most browsers block autoplay.
Is autoplay allowed in the iframe?
The allow attribute must include autoplay.
Is it inside a hidden tab or popup?
Players that start hidden may not autoplay; start them when shown.
Is embedding allowed?
Some videos disable embedding — they won’t play on other sites.
Does the page use a cookie banner?
Consent tools can block YouTube until visitors accept.
Good practice for autoplay
Autoplay short, silent clips; let people start longer videos themselves.
Show captions so muted autoplay still communicates.
Avoid several autoplaying videos on one page.
Why browsers block autoplay with sound
Unexpected sound is one of the most common complaints about websites, so browsers restrict it. Chrome always allows muted autoplay and allows sound only after the user has interacted with the site or has a history of watching media on it. Safari on iPhone and iPad allows muted inline autoplay, but not with sound. The practical rule is simple: autoplay muted, and let people turn sound on. Background: Chrome’s autoplay policy.
Autoplay a YouTube playlist
<iframe
src="https://www.youtube.com/embed/videoseries?list=PLAYLIST_ID&autoplay=1&mute=1"
title="YouTube playlist" allow="autoplay; encrypted-media" allowfullscreen></iframe>The first video starts muted and the playlist continues automatically.
Autoplay inside a popup or modal
Don’t load the iframe until the popup opens — otherwise it plays hidden. Insert the iframe (or call playVideo() through the API) in the click handler that opens the popup. Because the click is a user gesture, many browsers even allow sound. Remove or pause the player when the popup closes.
Autoplay, speed and SEO
An autoplaying embed loads the YouTube player immediately, which adds weight to the page. Keep autoplay for above-the-fold hero moments, and lazy-load other embeds so they don’t compete with your main content. Search engines don’t reward autoplay itself — they reward pages people stay on.
On this page
