YouTube embeds can severely slow page load times due to blocking thumbnail image requests. Using the IntersectionObserver API combined with the Plyr video library, you can defer creating video player instances until they enter the viewport. This approach reduced one site's load time from several seconds to milliseconds when handling 42+ embedded videos on a single page.

3m read timeFrom khalidabuhakmeh.com
Post cover image
Table of contents
Why Are YouTube Embeds Slowing My Page Load TimesUsing Plyr For YouTube EmbedsUsing IntersectionObserver To Create Plyr InstancesConclusion
1 Impression