Lazy Load Embedded YouTube Videos

It is a known fact that youtube videos slow down the sites. So why is speed so important? Because the decrease in page speed also affects your google ranking.

YouTube embed videos are added to the page with <iframe> tag and when this iframe is loaded, many resources are loaded with it. In this example page, which does not use any other source other than youtube video, 17 sources with 652 KB size are loaded.

How it works?

The lazy load feature works the same for youtube videos, just like it does for images. The iframes will load only as they come into view when the user scrolls down.

In addition, If a youtube embedded video comes into view when the user scrolls down, instead of directly loading youtube source, only the picture of the video will be loaded. YouTube resources are loaded when the image is clicked, so there is no need to load resources for non-watched videos.