Lazy-Loading Videos in Webflow Without Killing Performance

July 1, 2025

Lazy-Loading Videos in Webflow Without Killing Performance

Videos can be a powerful part of your website — they capture attention, tell stories, and increase engagement. But if you’ve ever embedded a YouTube or Vimeo video in Webflow, you’ve probably noticed something frustrating: your page speed drops.

That’s where lazy loading comes in. It’s a simple technique that helps videos load only when needed, keeping your website fast and your core web metrics happy.

In this post, I’ll show you how I lazily load videos in Webflow without sacrificing performance or user experience.

Why Lazy Loading for Videos Matters ?

When you embed a video directly into a page using an <iframe>, the browser loads:

  • The full player script (which can be heavy)
  • Tracking scripts (from YouTube, Vimeo, etc.)
  • Player thumbnails and UI

All of this happens before the user even views the video, slowing down the initial load.

Lazy loading avoids this by delaying the video loading until:

  • The user scrolls to the video
  • Or clicks the play button

This means:

  • Faster page loading
    Lower bounce rates
    Better SEO and performance

Thumbnail + Play Button (Manual Lazy Loading)

One of the most effective ways to lazy load a video is to replace the iframe with a thumbnail and load the actual video with just a click.

  1. Display thumbnail (e.g. YouTube preview image)
  2. Add custom play button
  3. When clicked, replace thumbnail with actual video

Step 1: Embed HTML block
html
Copy
Edit
<div class="video-wrapper" onclick="loadVideo(this)">
<img src="https://img.youtube.com/vi/VIDEO_ID/hqdefault.jpg" alt="Video thumbnail" />
<div class="play-button"></div>
</div>

Step 2: Custom script (in the footer)
html
Copy
Edit
<script>
function loadVideo(container) {
const videoId = "VIDEO_ID"; // Replace with your actual video ID
container.innerHTML = `
<iframe src="https://www.youtube.com/embed/${videoId}?autoplay=1"
frameborder="0"
allow="autoplay; encrypted-media"
allowfullscreen>
</iframe>`;
}
</script>

Use a high-resolution thumbnail and preload it for a smoother UX.

Lazy Loading Based on Scrolling with Intersection Observer

This method automatically loads videos only when they enter the viewport.

Wrap your video in a div with the data-src attribute

When the user scrolls to it, JavaScript injects an iframe

Step 1: HTML Embed Block in Webflow
html
Copy
Edit
<div class="lazy-video" data-src="https://www.youtube.com/embed/VIDEO_ID"></div>src="https://www.youtube.com/embed/VIDEO_ID"></div>

Step 2: Script (before the </body> tag)
html
Copy
Edit
<script>
const lazyVideos = document.querySelectorAll(".lazy-video");
const observer = new IntersectionObserver((entries, obs) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const div = entry.target;
const iframe = document.createElement("iframe");
iframe.src = div.dataset.src;
iframe.setAttribute("frameborder", "0");
iframe.setAttribute("allowfullscreen", "");
iframe.setAttribute("allow", "autoplay; encrypted-media");
div.appendChild(iframe);
obs.unobserve(div);
}
});
});
lazyVideos.forEach(video => observer.observe(video));
</script>

This method is best when you want autoplay on scrolling or there is no manual play button.

Reserve space to prevent layout shifting (CLS fix)

When you dynamically load an iframe, it can shift other content — which hurts your CLS (Cumulative Layout Shift) score.

Use a container with a fixed aspect ratio to “reserve” space for the video:

css
Copy
Edit
.video-wrapper {
position: relative;
padding-bottom: 56.25%; /* 16:9 aspect ratio */
height: 0;
overflow: hidden;
}
.video-wrapper iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}

This ensures that the layout remains stable while the video loads.

Here are some tips I follow for smooth lazy loading in Webflow:

  1. Use optimized thumbnails (compressed JPGs or WebP)
  2. Don’t autoplay unless necessary as it can impact user experience
  3. Use one strategy consistently per page to avoid conflicts
  4. Test on mobile devices and slow connections to ensure performance
  5. Check results in PageSpeed ​​Insights or Lighthouse

Lazy loading videos in Webflow is one of the easiest ways to:

  • Improve performance
  • Reduce bounce rate
  • Improve SEO
  • And provide a better and faster experience for your users

Whether you’re showcasing a product demo or a background video hero section, using one of the methods above will help you bring your designs to life without sacrificing speed.

Back to blog page