Please learn how to create a block for embedding videos from YouTube.
A man has created a plugin that does wonders.
https://ru.wordpress.org/plugins/mihdan-lite-youtube-embed/
Your block for displaying YouTube videos on the page creates a very large load and loads a lot of code.
Perhaps the visitor will not watch the video, but the entire YouTube page is loaded into the frame, which is twice as heavy as my site.
Why didn’t you lazy load videos?
Why load a video into a frame without knowing in advance whether the visitor will watch it?
Why couldn’t it be done in the same way as I indicated above, using the link?
In general, your work is good, but many blocks are just some kind of nightmare, there is neither logic nor optimization.
Hi,
I understand what you are saying. Most of the blocks that have problems were added from the beginning of the theme, when the requirements were not so high, but the problem is that as time passed, new elements were added and the old ones were often not optimized enough to be in step with the present.
If you want you can use that plugin, I think it should not be a problem.
What I can recommend is to try the video playlist, this element use a cache that will provide better results – https://i.imgur.com/ZuGjEsc.png – https://forum.tagdiv.com/video-playlist-2/
Thank you!
Caline, thanks for your reply.
I just wrote about the playlist above, I just didn’t quite accurately formulate my idea, sorry for that.
The playlist you specified in the example, link and screenshot has big problems.
Caching doesn’t help at all.
The playlist loads the entire content of the YouTube page in a frame, and this frame slows down the entire site and the rest of the code loading.
You did not take into account that YouTube, in the light of recent events, has slowed down the download of content in many countries, for example, Ukraine and Russia and many other countries.
As a result, the page of the site where this playlist is embedded takes a very long time to load, more than 20 seconds.
I provided you with a link to the plugin above so that you can see and understand how you can optimize your code so that the entire site does not slow down.
Uploading a YouTube video in a frame is not right, it slows down the entire site.
You need to do lazy or delayed loading of the movie, without using a frame.
And if the visitor wants to watch the video, then load the frame and load the video into it.
All this is easily implemented using JS, so I don’t understand why you made this module in a simple but very harmful way for the webmaster.
You are using the YouTube API for video previews.
But for some reason, you do not use this API for the video itself, but load it into a frame.
It would be correct to display not a frame, but a preview of the video with a play button and a light version of the player.
And when the visitor clicks on the play button – upload the frame and the contents of this frame to the site.
In general, look and study this plugin, it will tell you how to optimize your code so that the site flies even when you embed videos from YouTube.
-
This reply was modified 3 years by
Aleksey Petrov.
Thank you.
It would be great if the module could be improved.
Here is another example of implementing a quick download from YouTube, from the same topic, for your programmers:
https://paulirish.github.io/lite-youtube-embed/
Thanks for the feedback and good luck with the development!