Slow pages that carry YouTube videos are a common question, and the cause is usually not the server. Every standard embed pulls most of a megabyte of player files from YouTube as the page opens, whether or not anyone watches. A page with several embeds gets slow and clunky in the browser. The good news is that the fix sits entirely inside WordPress, and you can apply it yourself in a few minutes.
Why the hosting cannot speed up an embed
Your page cache, the server and any CDN in front of the site deliver your own pages and files. The YouTube player is not one of them. Its scripts and frames come from YouTube’s servers, and the browser fetches them after your page arrives. A faster server makes your HTML arrive sooner, but the browser still has to download and run the player for every embed on the page. The only way to reduce that work is to stop the player loading until a visitor wants it, which is what lazy loading does.
Turn it on in your optimisation plugin
For most sites this is the quickest route, because it fixes every page at once. The plugin replaces each embed with a preview thumbnail and a play button, and only loads the real player when the visitor clicks.
- WP Rocket: Media tab, enable LazyLoad for iframes and videos, then tick “Replace YouTube iframe with preview image”. WP Rocket uses a lower resolution thumbnail by default, so install its companion add-on for choosing the thumbnail resolution, otherwise the previews look grainy.
- FlyingPress: enable lazy loading for iframes and its YouTube placeholder option.
- Perfmatters: Lazy Loading section, enable iframes and videos along with “YouTube Preview Thumbnails”.
Clear the page cache after saving. The swap is applied to the cached copy of each page, so nothing changes until the cache is rebuilt.
Pages have to be cached for this to work
Plugin optimisations are applied as the page is built for the cache. If a page is excluded from caching, the plugin leaves its embeds alone. Check your plugin’s “never cache” list for pages that contain videos. Landing pages and pages with forms are sometimes excluded for good reasons, in which case use one of the manual methods below on those pages.
If your theme or builder fights it
The plugin route works on most sites, but some themes and page builders output videos in a way the plugin cannot replace. Divi is one where this has been a problem. If WP Rocket or FlyingPress leaves your videos untouched, try Perfmatters for the video lazy loading; it handled the Divi case shown in the video.
Preview images in the page builder
Most popular themes and page builders have a video widget that takes a YouTube link and a preview image, and some let you change the play icon. This is the lightest option of all, because the page loads nothing but an image until someone clicks. The downside is time: every existing video has to be edited by hand and given a preview image. A sensible split is the plugin for the whole site and the builder widget for the homepage and your other busiest pages.
Doing it by hand
For an embed you have pasted in as HTML, the simplest change is to add loading="lazy" to the iframe tag:
<iframe loading="lazy" src="https://www.youtube.com/embed/VIDEO_ID" title="Video title" allowfullscreen></iframe>
The browser then waits until the visitor scrolls near the video. That suits videos further down the page, but a video at the top loads as normal because it is already in view. The video above also shows a srcdoc version that displays the thumbnail and loads the player on click. Be aware that most browsers no longer autoplay a video with sound, so visitors may need to click twice.
Checking it worked
- Open the page in a private window so you see the cached version a visitor gets.
- Open your browser’s developer tools, go to the Network tab and reload.
- Filter for “youtube”. Before you click play you should see the thumbnail image only, with no player scripts. After you click, the player files load.
When to contact us
Open a ticket from the client area if the swap does not appear after clearing the cache, if a page you expect to be cached is not, or if enabling video lazy loading breaks the layout of a page. Include the page URL, the optimisation plugin you use, your theme or page builder, and what you have already tried. Our support team can check how the page is being cached and served, and help you find the setting that applies.
