• yarintosh

    (@yarintosh)


    I know it’s a bit of an oxymoron, but I have autoplay videos on the bottom of my page and I want them to start play and load only when viewed or scrolled.

    Couldn’t find any plugin that does it, any suggestions?

Viewing 3 replies - 16 through 18 (of 18 total)
  • Thread Starter yarintosh

    (@yarintosh)

    Well, that’s a bummer. I just wanted Lazyload to make the page load faster since there’s no reason for it to load before scrolling.

    It’s kind of odd that there’s no plugin for that.

    tugbucket

    (@tugbucket)

    https://github.com/tugbucket/lazy-load-videos

    I updated the Javscript file to handle actually loading on scroll. In order for this to work, you will have to change your HTML

    <video class="elementor-video" src="https://www.barillio-barware.com/wp-content/uploads/2020/11/5-1.m4v" autoplay="" loop="" muted="muted" playsinline="" controlslist="nodownload" played="true"></video>
    

    to

    <video class="elementor-video" data-src="https://www.barillio-barware.com/wp-content/uploads/2020/11/5-1.m4v" autoplay="" loop="" muted="muted" playsinline="" controlslist="nodownload" played="true"></video>

    Note the difference. Instead of src="<path>" change that to data-src="<path>" so the new HTML does not have src="" what this will do is make a blank <video> element and when it scrolls into view, it will take the data-src and create the src thus “lazy loading” the video. The original play/pause still works.

    Thread Starter yarintosh

    (@yarintosh)

    You are a legend! It works and I have already replaced all the videos on the site.

    I couldn’t find a solution for this anywhere and you helped me so much, thank you sir for saving me a lot of time, I appreciate it.

Viewing 3 replies - 16 through 18 (of 18 total)
  • The topic ‘Lazy Load video with autoplay’ is closed to new replies.