• This might be out-of-scope for this plugin, but if the iframe is lazy-loaded by the Litespeed Cache Plugin, then your .play-button is still added to the page, but the click doesn’t trigger autoplay on the iframe.

    By watching the behaviour in the browser inspector, I can see that your script still removes the template tag when the button is clicked. Your script adds the iframe to the page, which is evident because I’ve modified your script to add the data-wilkinson attribute. I’ve also added autoplay="autoplay", just in case that was the problem: it isn’t. This doesn’t actually start the video playing when the iframe is inserted.

    If I disable LCP on this page, the autoplay works as you originally programmed it. Therefore, I’d suggest you check to see whether the iframe is being lazy-loaded. The HTML of the iframe when it’s being lazy-loaded by LCP is:

    <iframe data-lazyloaded="1" src="about:blank" title="Haytor 2023" width="1280" height="720" data-src="https://www.youtube.com/embed/mBaxkFq2jxM?feature=oembed&amp;hq=1" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen=""></iframe>

    (Note: I’ve since deactivated lazy-loading of the iframes in LCP so that the page works as intended.)

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Mark Howells-Mead

    (@markhowellsmead)

    First guess would be that you’re overriding the allow attribute, which might cause a conflict.

    Thread Starter Mark Howells-Mead

    (@markhowellsmead)

    Additional nice-to-have would be that the script stops any other videos on the page from playing when autoplaying a new video.

    Plugin Contributor Mark Wilkinson

    (@wpmarkuk)

    Can you help with your settings for Litespeed Cache please? I have installed this in my dev env add turned on lazy loading of iFrames but everything seems to work fine for me?

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.