Answer the question
In order to leave comments, you need to log in
How to optimize a wordpress site?
the question is the following:
on the main page there is an insertion of a video from YouTube through an iframe. As a result, the gtmetrix test is very swearing that YouTube loads the script by almost 1mb. The site is made on WP, connected various plugins for lazy-load, etc. - anyway, this script is loaded and gtmetrix people are indignant at it. In google page speed, the first issue is to reduce the server response time. I suspect for the same reason. Please help me to solve this problem! Thank you in advance
Answer the question
In order to leave comments, you need to log in
I did this: the player made it up by itself (the picture has a large play button in the center). The picture from the YouTube video stretches. There are no scripts. By clicking on the play button, a modal window is launched - the video is played in it. Here after a clique all scripts also are loaded.
Why did I pull the picture from YouTube, and not from my server? This is how I check the availability of the video. It often happens that the copyright holders force them to remove the content and sometimes you go to the page - and the video is deleted. Thus, I automatically send a letter to my mail if the picture returned a 404 response to me. I just find a similar video on YouTube and replace the links (I'm talking about movie trailers)
Replace the iframe with an image, and remove the link from the iframe altogether.
As the site loads, hide the image and insert a link to the video in src (the link can be stored in data-attr)
Download the page completely, and then show the video!
Those. not just lazy, but with a delay until the document is fully loaded.
1. Launching the video - only after the full loading of all page resources.
2. Use the Youtube API to fully control how the video is downloaded and played.
It is necessary to connect caching and compression of scripts.
For example, you can use the following bundles of plugins (you need to test them and choose the most suitable one):
1) Clearfy PRO + WP Fastest Cache Premium
2) Clearfy PRO + WP Rocket + Rocket lazy load
3) Clearfy PRO + Autoptimize
Load the iframe with a timeout, for example, after 3-4 seconds, before that you can show the picture. This time should be enough for the testers to complete their tests and give good results. We did the loading of scripts in this way, the content was loaded from user actions (scroll, cursor shift in the document area, click, touch) or simply loaded after 3 seconds. The method is not very good, but our site is completely on Ajax, so the solution was the best.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question