![](https://i-blog.csdnimg.cn/blog_migrate/1e0d8ef9b3ac60b7bcfb2389317225a0.png)
wordpress 加载慢
Videos are great for improving user engagement on your website. However, one downside of embedding videos is that it slows down your website. In this article, we will show you how to add lazy loading for videos in WordPress and improve your page speed.
视频非常适合提高网站上的用户参与度。 但是, 嵌入视频的一个缺点是它会降低您的网站速度。 在本文中,我们将向您展示如何为WordPress中的视频添加延迟加载并提高页面速度。
视频的延迟加载如何工作? (How does Lazy Loading for Videos Work?)
![Lazy Loading for Videos Lazy Loading for Videos](https://i-blog.csdnimg.cn/blog_migrate/d096a4382a841151c50c0611542ae279.png)
Wondering what exactly is lazy loading, and how does it work?
想知道延迟加载到底是什么,它是如何工作的?
When you embed a video on your site, you add additional external scripts and files that needs to be loaded. Since there is more to load, your website loads slower.
将视频嵌入网站时,会添加其他需要加载的外部脚本和文件。 由于加载的内容更多,因此您的网站加载速度较慢。
Video lazy loading replaces the embedded Youtube and Vimeo videos with a clickable preview image. When your visitors click on the image, it loads and play the video.
视频延迟加载将可点击的预览图像替换为嵌入式Youtube和Vimeo视频。 当您的访客单击图像时,它将加载并播放视频。
Since images are a lot smaller in size than videos, the lazy loading technique significantly improve page speed.
由于图像的大小比视频小得多,因此延迟加载技术可以显着提高页面速度。
Now that you know the advantages, let’s take a look at how to lazy load YouTube and Vimeo videos in WordPress.
现在您已经知道了优点,让我们看一下如何在WordPress中延迟加载YouTube和Vimeo视频。
影片教学 (Video Tutorial)
If you don’t like the video or need more instructions, then continue reading.
如果您不喜欢该视频或需要更多说明,请继续阅读。
如何在WordPress中为视频添加延迟加载 (How to Add Lazy Loading for Videos in WordPress)
First thing you need to do is install and activate the Lazy Load for Videos plugin.
您需要做的第一件事是安装并激活“ 视频延迟加载”插件。
This plugin works out of the box, and you do not need to edit any lazy loading jQuery scripts or any code for that matter.
该插件开箱即用,您无需为此而编辑任何延迟加载的jQuery脚本或任何代码。
To see that your lazy loading is working, all you need to do is view a post or page that contains a YouTube or Vimeo video. You will notice that the default players are replaced by a video thumbnail and a play button.
要查看您的延迟加载是否有效,您所需要做的就是查看包含YouTube或Vimeo视频的帖子或页面。 您会注意到默认的播放器已被视频缩略图和播放按钮取代。
![A lazy load video with thumbnail and play button A lazy load video with thumbnail and play button](https://i-blog.csdnimg.cn/blog_migrate/0b1f451e779d04a65d95aed73b90b3dd.png)
When you click on the image, it will load the video and play it.
当您单击图像时,它将加载视频并播放。
There might be a slight second (negligible) delay in loading the video, so please don’t think that the lazy loading is not working.
加载视频可能会延迟一秒钟(可以忽略不计),因此请不要认为延迟加载无法正常工作。
Even though this plugin works out of the box, there are still settings which you can configure based on your needs.
即使此插件开箱即用,仍然可以根据需要配置一些设置。
On the post editor screen, you can choose the thumbnail quality for YouTube video embeds.
在帖子编辑器屏幕上,您可以选择YouTube视频嵌入的缩略图质量。
![Controlling YouTube thumbnail quality for posts and pages Controlling YouTube thumbnail quality for posts and pages](https://i-blog.csdnimg.cn/blog_migrate/cfae11132314a795b0cd5016e9923782.png)
Aside from the thumbnail quality, there are further customization options available if you head over to Settings » Lazy Load for Videos.
除了缩略图质量之外,如果您转到设置»视频的延迟加载 ,则还有其他自定义选项可用。
![Settings page for lazy load for videos WordPress plugin Settings page for lazy load for videos WordPress plugin](https://i-blog.csdnimg.cn/blog_migrate/81d6df02d2c44f9c36481d126f36c2cd.png)
On the general settings tab, you can customize the appearance of the video thumbnails. You can enable responsive mode, choose play button style, use custom CSS, and even enable schema.org markup.
在常规设置选项卡上,您可以自定义视频缩略图的外观。 您可以启用响应模式,选择播放按钮样式,使用自定义CSS,甚至启用schema.org标记。
This plugin supports both YouTube and Vimeo. You can find provider specific settings by clicking on the respective tabs.
此插件支持YouTube和Vimeo。 您可以通过单击相应选项卡找到提供商特定的设置。
On the YouTube tab, you can choose colors, thumbnail quality, disable related videos and annotations, etc. You can even disable lazy load for YouTube videos.
在YouTube标签上,您可以选择颜色,缩略图质量,禁用相关视频和注释等。甚至可以禁用YouTube视频的延迟加载。
![Lazy load for YouTube settings Lazy load for YouTube settings](https://i-blog.csdnimg.cn/blog_migrate/55fadc45aa895ac21d5587f0deab4f79.png)
Similarly, on the Vimeo settings tab you can choose control colors, hide or display video title, and disable lazy load for Vimeo videos.
同样,在Vimeo设置选项卡上,您可以选择控制颜色,隐藏或显示视频标题以及禁用Vimeo视频的延迟加载。
![Lazy load for Vimeo Lazy load for Vimeo](https://i-blog.csdnimg.cn/blog_migrate/d3daaf70246ee36c1795b08688da170d.png)
That’s all. We hope this article helped you add lazy load for videos in WordPress.
就这样。 我们希望本文能帮助您为WordPress中的视频添加延迟加载。
To further boost your website’s speed you will need to setup a WordPress CDN solution with W3 Total Cache plugin.
为了进一步提高网站速度,您将需要使用W3 Total Cache插件设置WordPress CDN解决方案 。
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Google+.
如果您喜欢这篇文章,请订阅我们的YouTube频道 WordPress视频教程。 您也可以在Twitter和Google+上找到我们。
翻译自: https://www.wpbeginner.com/plugins/how-to-easily-add-lazy-loading-for-videos-in-wordpress/
wordpress 加载慢