Lazy load YouTube video for 500ms better mobile speed.

WordPress Mobile Speed

Updated


There are no affiliate links on PagePipe.

“A single YouTube embed can load up to 400KB of data before you even hit the play button.”

Is a 2-second differential important? Not if your target is an average 8-second page load.

It’s not really about measuring speed. It’s about human attention span and expectation. 2 seconds is the sweet spot for page loads (today). But one second feels seamless. User experience is then optimal.

If you want excellent pages (we mean in the top 1-percent quality range or under 1-second page loads), you have to take the video into consideration. What if a form is also on the page? And there is HTTPS/SSL? Then videos just add to the speed overhead.

How good is good enough is always a compromise. Can you get 2-second load times on shared hosting? Yes.

Speed is just a feature. Make your website fast and useful, too. If it’s not useful, who cares if it’s fast.

Average load time for mobile sites is 19 seconds over 3G connections.

Do website owners have anxiety about a half second? Yes. That’s a major problem (they think). But not for someone on a desktop with fiber connections.

Lazy Loading YouTube or Vimeo videos

Set up a Youtube account to host your videos. Place the YouTube link in your page or post body text. You don’t need to move video down the page. That isn’t necessary. Lazy loading videos occurs anywhere on the page. It doesn’t have to load below the fold. It’s different from lazy loading still images like JPEGs or PNGs.

We experimented with Lazy Load for Video plugin. We like the plugin. But have found it can conflict with other plugin’s shortcodes on a page or post. Sadly, it doesn’t work with Elementor page builder.

Using the Lazy Load for Videos plugin can save 500 to 700 milliseconds in page load time. Studying plugin blog reviews about the Lazy Load for Video plugin, we learned the following about the settings:

There is an option to load CSS/JS only when needed. It should improve the load time. It is not declared but is apparently a minification technique since the blog author warns that it could break the site. Just like any other minification plugin can. If so, we just deselect the option.

Responsive Mode: It is recommended.

Play Button: The author gives 5 different options. We prefer using the one with the most “YouTube-looking” interface. But it’s not the fastest. “CSS only” setting means code is loaded (faster) because there is no image to load. We don’t know if the speed gain would be significant.

Thumbnail Size: It can be set to “Standard” or “Cover.” We couldn’t tell any difference and used “cover.”

“Update Posts” button at the bottom. The blog review said, “If you are having trouble seeing your video change then you probably need to click this button. Especially right after configuring the plugin for the first time.”

If should be labeled, “always push this” instead of “if nothing is wrong” push this. We suspect it’s some kind of purge of cataloged pages or posts (like a cache or database).

After installing, we did have trouble with plugin activation on some videos. We clicked the button and it fixed the problem. We knew nothing about this button’s purpose. It isn’t mentioned in the plugin read.me documentation!

★★★★★
Lazy Load for Videos
Zip file size: 376k
Active Installs: 10,000+

One thing we’ve found is an option to “Hide-related Videos” with a checkbox. This sounds like a good thing if you don’t want to send viewers off to watch competitors YouTube videos. This function is available in Elementor’s video provisions, also (see below). Update: Google removed the ability to turn off recommended videos. There is a workaround to only recommend videos on your YouTube channel. So plugin authors are in process of reworking how to suppress taking visitors away from your site. More on this as news develops. You should still do lazy loading of videos for speed.

End of YouTube video attempts to entice visitors away from your site. Sometimes to competitor sites. Bad! Defeating this *non-feature* is an option with the Lazy Load for Videos plugin. There are other methods but we’ve found this the simplest way to keep visitors engaged with your site content.

The Lazy Load for Videos plugin read.me file claims videos on posts and pages are both activated.

Of interest: Jetpack by WordPress.com offers an extension called Shortcode Embeds. It makes Lazy Load for Videos break. The cure is simply to disable the extension. Or like us, don’t use Jetpack! This is a known issue published in the read.me file.

BEFORE: Lazy load for video plugin installed. The test page has 13 one- to seven-minute duration videos. Pingdom is a best-case scenario. Load time is 3.15 seconds. Using WebPagetest.org, the test page loaded in over 7 seconds (worst-case).

 

AFTER: lazy load for video plugin installed. Same test page. Pingdom is a best-case scenario is now 1-second with an unprimed cache. With cache, page load is 853 milliseconds.

We’ve also found this good lazy load plugin:

★★★★
Lazy Load XT
Active installs: 3,000+

Zip file size: 29k

The plugin author claims this is the fastest and lightest lazy load plugin in the WordPress Plugin Directory. You can lazy load images, YouTube and Vimeo videos, and iframes. We’ve been testing it for several months and find it a good alternative when the other Lazy Load for Videos plugin conflicts with other plugins. We find this a common problem and it explains the low retention rate. Lazy Load XT appears a little slower in the view screen when loading images and video. It uses a fade-in method. This plugin does work with Elementor page builder.

Both plugins enqueue jQuery, a negative effect for speed. If your theme isn’t loading that JavaScript library, we recommend selective activation of these plugins only on the pages where needed. This will keep your site running fast. Also, use Instant jQ to keep things fast.

Here’s a comparison on a bare-bone GeneratePress theme with Gutenberg page-builder plugin – and a YouTube video embedded.

NOTE: If you use a page builder like Elementor, Lazy Load for Videos will load but doesn’t work to reduce load time. But LazyLoad XT, works fine. Go figure. Both work with Gutenberg.

No lazy load baseline.

Page load time: 1.5 seconds. Page weight: 720k. The video weight is 526k – 72 percent of total weight.

Lazy Load for Video Plugin

Page load time: 815 milliseconds. Page weight: 94k.

LazyLoad XT Plugin

Page load time: 735 milliseconds. Page weight: 724k.

BJ Lazy Load Plugin

Page load time: 691 milliseconds. Page weight: 724k. Using Elementor instead of Gutenberg as on other tests.

Even though LazyLoad XT and BJ Lazy Load are faster loads, their page weight and bandwidth consumption for mobile are 7X higher. This makes Lazy Load for Video plugin more attractive for a mobile experience. All these plugins video preview and play button are scalable and optimized for mobile devices.

Lazy Load for Videos plugin is our preferred plugin between these two. Both work and if one has a conflict – try the other one. You can use both these plugins with selective activation if your posts have shortcode conflicts. We prefer the UX behavior of Lazy Load for Videos.

If you activate both plugins simultaneously, Lazy Load for Videos will take precedence since it loads first. Page weight is increased by these plugins. Both plugins load globally. Loading an embedded YouTube video without lazy loading doesn’t enqueue jQuery. But this small gain is swamped by the huge video load time.

There’s not too much overhead for a single video. What happens when you have a video library or a blog with multiple videos?

YouTube loads a number of files (8 requests) with each iframed video. Web pages with multiple Youtube videos slow down due to these multiple HTTP requests and downloads. Preventing or delaying embedded YouTube video player loads is the speed goal.

The fastest websites have no JavaScript, no CSS, and require no database calls. YouTube does all this and preloads third-party ad stuff you’ll see at the end of the video (related videos).

Video-loads slow a page down by a half-second typically. It’s only a big deal if a half second is important to you. Our goal is a 2-second load time. If you put a video on a home page, boom! Potentially, 25 percent of the performance budget is shot.

One example is the very video page where you saw the robots. Before plugin: 3.15 seconds. After: 1.03 seconds. Supposedly, it should be worse – but caching seems to help YouTube somehow. There are 13 videos on that page. Do people do that cramming? Yes. A video library page is a common practice.

LAZY LOAD YouTube VIDEOS WITH ELEMENTOR

This is a basic widget. It’s included. No purchase necessary.

Elementor basic widget for adding video to a page.

Image Overlay section: Find it at the bottom underneath the video section. (It’s practically hidden. Scroll down to the end of the Elementor video section)

Image Overlay at bottom after scroll.

Settings
Image Overlay: Select Show

When Image Overlay is set to Show, the following options become available:

  • Image: Set your static overlay image from the media library (an optimized JPEG you choose).
  • Lazy Load: Set to YES.
  • Image Size: Set to full.
  • Play Icon: Slide to YES to show a Play Icon (triangle in circle)
  • Lightbox: Leave off.

This defers loading of video resources until the user clicks the Play button. Lazy load replaces the video embed code with a lighter weight static image of your choice. And an optional play icon on top of the static image. The video is only loaded when the user clicks the image.

This speeds up the initial page load time by 500 milliseconds (typically per video on a page).

Note: Videos will not autoplay if an Image Overlay is set. You don’t want autoplay anyway. It’s considered intrusive and bad user experience. Let the user choose to activate the video sound and play.


From surveys, the top three biggest challenges for WordPress users are: 52% performance issues, 41% security issues, 35% site-breaking updates. NOTE: These are all fear related – not reality related.

Most common goals for WordPress websites:

  • 64% increase traffic
  • 43% increase revenues
  • 39% become more efficient at running a site

All these three are profit related.

https://pagely.com/blog/wordpress-survey-2018/

Godspeed-

Steve Teare
performance engineer
May 2024

 

PagePipe Site Tuning Services for Speed

Instead of band-aid approaches, we drill down to the root cause of your slow site. This is origin optimization. Also known as site tuning. To do this, we analyze site components:

  • Hosting
  • Theme
  • Plugins
  • Scripts and third-party services.
  • Images and media library.
  • We minimize globally loading plugin effects.

Find out more details about Site TuningGet Speed!