Chat with StauUsually replies in seconds

Before we start, leave your email. If the chat drops, our reply reaches you there.

Stau

Videos on Your Website: Performance Tips

Learn how to use videos on your site without slowing it down, and discover best practices for embedding and compression.

The Video Dilemma on the Web

Videos are one of the most engaging content formats on the internet. Pages with video can have conversion rates up to 80% higher than pages without. However, videos are also one of the biggest performance culprits, potentially adding seconds to load time if not implemented correctly.

The challenge is finding the perfect balance: using videos to engage and convert, without sacrificing site speed. This article shows you how to achieve that.

Self-Hosted vs. External Platforms

The first decision is where to host your videos. Hosting directly on your server (self-hosted) might seem simpler, but it's usually the worst option for performance.

Platforms like YouTube, Vimeo, or Wistia offer significant advantages: global CDN for fast delivery, automatic transcoding for different devices, adaptive streaming that adjusts quality based on user connection, and infrastructure optimized for serving videos.

The golden rule is: never host heavy videos on the same server as your website. This consumes bandwidth, memory, and can slow down the entire site.

Lazy Loading Videos

Even when using embeds from external platforms, each embed loads scripts, styles, and preloads video data. A YouTube embed, for example, can add over 500KB of resources to your page.

The solution is to implement lazy loading: the video only loads when the user interacts with it or when it enters the viewport. Popular techniques include:

  • Facade pattern: Display a static thumbnail of the video with a play button. The real embed only loads when the user clicks.
  • Intersection Observer: Use the browser API to detect when the video enters the visible area and only then load the embed.
  • lite-youtube-embed: A lightweight component that replaces the standard YouTube embed, reducing the initial impact from 500KB to less than 10KB.

Optimizing Self-Hosted Videos

If you really need to host videos on your own server, follow these practices to minimize the performance impact:

Use the MP4 format with H.264 codec for maximum compatibility, or WebM with VP9 for better compression. Offer multiple resolutions and use the preload="none" or preload="metadata" attribute on the video tag to avoid automatic download.

Never use autoplay with heavy videos. If you need a background video (hero video), use highly compressed, short versions (5-15 seconds) without audio. Consider replacing them with optimized GIFs or CSS animations for similar visual impact.

Impact on Core Web Vitals

Poorly implemented videos mainly affect two metrics: LCP (Largest Contentful Paint), if the video is the largest visible element, and CLS (Cumulative Layout Shift), if the video space is not reserved correctly.

To avoid CLS, always set width and height on the video container, maintaining the correct aspect ratio. Use CSS with aspect-ratio: 16/9 to ensure space is reserved before the video loads.

To protect LCP, avoid having the video as the main element above the fold. If you need a hero video, consider using a poster (static image) that loads instantly while the video downloads in the background.

Written by

The Stau team · Stau

We build websites that build themselves, for American small businesses that would rather run the business.

Keep reading

Your site can have all of this
built in, by tonight.

The builder writes, designs, and structures your site with everything these articles teach. Watching it happen is free.

Full preview · No account · No credit card