roy-bongers / youtube-oembed-lazy-load

WordPress plugin to Lazy Load YouTube video's in order to save bandwidth

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

YouTube oEmbed Lazy Load

This WordPress plugin replaces the default YouTube embed with a still (image) from the video and a play button instead of embedding the whole iframe. Only the image will be downloaded instead of the entire YouTube iframe (around 600kB). This makes your page render a lot faster which is especially important on mobile devices. When the play button is clicked the iframe will be loaded and the video wil start auto-playing (for mobile, see known issues).

Usage

Use the default WordPress embed shortcode. The video will automatically be embeded with a still instead of the original iframe.

[embed]https://www.youtube.com/watch?v=dQw4w9WgXcQ[/embed]

Requirements

  • PHP >= 5.6 with php-xml module.
  • WordPress with the classic-editor plugin installed and activated.

Installation

Using composer simply execute: composer require 'roy-bongers/youtube-oembed-lazy-load:*'

Known issues

Gutenberg support

The plugin only works with the Classic editor and not with the new Gutenberg editor. I'm not planning to add support for Gutenberg. If you want to add support for Gutenberg please fork the project.

Autoplay on mobile

Google Chrome and other browsers are blocking autoplay on mobile devices unless they are muted. The plugin tries to play the video with audio. If this fails the video will start muted.

About

WordPress plugin to Lazy Load YouTube video's in order to save bandwidth

License:GNU General Public License v3.0


Languages

Language:PHP 65.1%Language:JavaScript 24.4%Language:SCSS 10.5%