YouTube facade for Divi videos
A YouTube embed loads hundreds of kilobytes before anyone presses play. Use a click-to-play facade in Divi, by hand or automatically.
A single YouTube embed loads the YouTube player, its scripts and fonts as soon as the page opens — roughly half a megabyte and a lot of main-thread work, whether or not anyone watches. On a Divi landing page with a hero video, that alone can push mobile PageSpeed into the red and trigger the “Reduce the impact of third-party code” warning.
What a facade is
A facade shows a still thumbnail with a play button in place of the player. Only when the visitor clicks does it swap in the real YouTube iframe, usually with autoplay so one click starts the video. The page loads a few kilobytes instead of the whole player, and visitors who never watch never pay for it.
Option 1: by hand
- Use the video’s thumbnail,
https://i.ytimg.com/vi/VIDEO_ID/hqdefault.jpg, as an image with a play icon on top. - On click, replace it with
<iframe src="https://www.youtube-nocookie.com/embed/VIDEO_ID?autoplay=1" allow="autoplay; encrypted-media; picture-in-picture" allowfullscreen></iframe>sized to the same 16:9 box, so nothing jumps. - Or use the open-source
lite-youtubeweb component in a Divi Code module.
Divi’s Video module also has an Overlay image option. It shows an image first, but the YouTube iframe is still loaded behind it, so it helps the look, not the weight. And combining it with a lazy-load plugin’s own facade can leave the play button unresponsive — use one or the other.
Option 2: automatically
Doing this by hand for every video is tedious and easy to undo when someone edits the page. TurboCache turns every YouTube (including youtube-nocookie) and Vimeo iframe into a facade automatically, whatever produced it — Divi’s Video module, a Code module, the block editor’s embed, or a page builder from another plugin:
- Switch on Video facades (YouTube and Vimeo are on by default) on TurboCache → Settings → Content → Videos and frames.
- The thumbnail keeps the iframe’s width/height ratio, so there is no layout shift.
- One click loads the player with autoplay. The facade is a real button with a “Play video: [title]” label, reachable by keyboard.
- Divi video backgrounds are handled separately by the Divi video backgrounds shim (
preload="none"plus a poster). - Other iframes — maps, forms — are lazy-loaded when they scroll into view by Lazy-load frames.
To keep a particular video as a normal embed (for example one that must start muted on load), add its class to Exclude frames, or add data-no-lazy to the iframe.
Avoid the two-tap problem on mobile
Some facades build the player with an inline srcdoc page, which on certain mobile browsers needs a second tap to play. Swapping in the real embed URL with autoplay=1, as above, plays on the first tap in most browsers. Test on a real phone: tap once and the video should start.
Frequently asked questions
Does a YouTube facade hurt SEO?
No. Search engines find the video through the link in the page and your structured data, not by running the player. If video rich results matter, add VideoObject structured data with the thumbnail and embed URL.
Why does PageSpeed still show YouTube requests?
Usually because the page is not yet re-optimised or the test was made logged in. Test in a private window after the page has been rebuilt; only the thumbnail image from i.ytimg.com should load.
Will autoplay work after the click?
Yes. Browsers allow autoplay with sound after a direct click on the page, which is exactly what the facade click is.
Does Divi’s overlay image make the video lighter?
No. It only covers the player with an image; the YouTube iframe and its scripts still load with the page.
Did this answer the question? No — open a support request