If you use youtube Iframe on your website this approach will be interesting for you to optimize page speed.
Problem
You use the Iframe
probably you’ve noticed that your page is loading slower now. Especially if you have several video on the page.
It was needed 2.98 seconds on my page only for base.js which pull player functionality. Page loading took 6.58 seconds in total. Quite long.
I found Denis Chernikiov solution here.
Demo
So briefly, we pull only preview image instead of extra requests. And put play icon above preview - so it looks like player. So you don't do requests for youtube assets when page is loading and only if user wants to watch video youtube player will be loaded.
As result I decreased page loading time till 3.37 seconds.
Also you can check solutions here by stanislav.protasevich:
Leave a Comment