Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a native HTML5 video, start with loading="lazy" and preload="none", and give the video explicit dimensions and a poster. This lets the browser defer off-screen media while reserving space in the page. It is a request to the browser, not a guarantee: preload is a hint, and autoplay can make earlier downloading necessary.

Use native lazy loading for an HTML5 video

Put loading="lazy" on the <video> element. The browser then defers the video until it is within a browser-calculated distance of the viewport. Pair it with preload="none" to ask the browser not to preload video data, and include a poster and fixed dimensions:

<video controls loading="eager" preload="none" poster="poster.jpg" width="640" height="360">
  <source src="movie.webm" type="video/webm">
  <source src="movie.mp4" type="video/mp4">
  Your browser does not support HTML video.
</video>

Replace the example paths with files available to your site. Multiple sources let the browser choose a format it can play. The fallback text is shown when the browser cannot use the video element.

MDN describes native lazy loading as a way to defer network and storage bandwidth until the browser expects the video to be needed. It also recommends explicit dimensions: before a lazy video loads, it may otherwise have zero dimensions and cause content to reflow. MDN’s video reference documents the element’s attributes and behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why include both loading and preload?

They address different decisions. loading="lazy" concerns when the browser should begin loading the video based on its distance from the viewport. preload is a hint about how much media data to fetch. MDN and web.dev show them together; one does not replace the other. web.dev’s lazy-loading guide also demonstrates the combination with a poster.

Choose the right preload setting

Setting What it asks for When it may fit
preload="none" Do not preload video data. A sensible starting point when you want to avoid fetching media before playback is needed.
preload="metadata" Fetch metadata, such as duration. When showing metadata before playback is useful, while avoiding a request to preload the whole file.
preload="auto" Allows the whole file to be downloaded, even if the visitor may not play it. Use only when that earlier data transfer is intentional.

The HTML specification treats preload as a hint, so a browser may not follow it exactly. Also, autoplay takes precedence over preload: the browser needs to fetch media to start playback. If your goal is to stop an off-screen video from downloading, do not assume preload="none" will prevent that when autoplay is present.

Keep the layout stable and give visitors a useful preview

Set width and height to the video’s intended display dimensions, as in the example. If the design is responsive, CSS can scale the element while preserving its proportions:

Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option
video {
  max-width: 100%;
  height: auto;
}

Use a representative image in poster so the space reserved for the video has a useful preview while playback has not begun. With loading="lazy", the poster itself is deferred until the video is near the viewport; it is not a way to make the poster appear immediately for every off-screen video. Check that the poster path is correct and that its aspect ratio suits the video.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If your layout uses CSS rather than fixed HTML dimensions, reserve the space with an aspect-ratio box. The important outcome is that the page knows the video’s intended shape before its media loads, avoiding a sudden shift when it appears.

When to use IntersectionObserver instead

Native loading="lazy" is the simplest choice when the browser’s own timing is adequate. Use JavaScript when native media lazy loading is not supported in a target environment or when you need custom activation timing. The following pattern keeps the media URL in data-src until the video approaches the viewport, then activates the source and calls load():

<video class="lazy-video" controls preload="none" poster="poster.jpg" width="640" height="360">
  <source data-itgw-was-lazy-src="movie.mp4" type="video/mp4">
  Your browser does not support HTML video.
</video>
<script>
const observer = new IntersectionObserver((entries, obs) => {
  for (const entry of entries) {
    if (!entry.isIntersecting) continue;
    const video = entry.target;
    for (const source of video.querySelectorAll('source[data-src]')) {
      source.src = source.dataset.src;
      source.removeAttribute('data-src');
    }
    video.load();
    obs.unobserve(video);
  }
});
document.querySelectorAll('.lazy-video').forEach(video => observer.observe(video));
</script>

The observer callback activates each video the first time it intersects the viewport, then stops observing it. Removing data-src after assigning src avoids treating the source as still deferred. This is an implementation pattern, not a promise that every browser or site setup behaves identically. Test in the browsers and network conditions your audience uses.

JavaScript and fallback considerations

Browser-level lazy loading is deferred only when JavaScript is enabled. If you use an observer pattern, JavaScript is also required for the code that installs the source URL. Decide what should happen for visitors with JavaScript disabled rather than unintentionally leaving them with a permanently unavailable video.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

MDN identifies IntersectionObserver as the API for detecting when an element enters or exits the viewport. For compatibility-critical cases, its lazy-loading guidance lists scroll, resize, and orientation-change handlers as alternatives. Those event-based fallbacks require more care: the code must determine whether the element is close enough to the viewport and avoid doing unnecessary work on every event. MDN’s lazy-loading guide describes the API and fallback options.

Rank #4
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers

Handle autoplay and third-party players separately

Autoplaying native video

Autoplay changes the purpose of lazy loading: the browser must fetch media to begin playback, so autoplay takes precedence over the preload hint. If playback should wait until a visitor reaches the video, remove autoplay and let the visitor start it with the controls. If autoplay is essential, test the behavior rather than expecting preload="none" to prevent the required fetch.

YouTube and other iframe players

A YouTube embed or another hosted player is commonly an <iframe>, not a native <video> under your page’s control. The native video attributes do not control the player inside that frame. Defer the iframe itself or the player’s initialization instead. web.dev treats iframe lazy loading as a separate problem in its video lazy-loading guidance.

For an iframe, the native HTML loading attribute can be applied to the iframe, for example:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<iframe
  src="https://www.youtube.com/embed/VIDEO_ID"
  title="Video title"
  loading="eager"
  allowfullscreen>
</iframe>

Replace the example URL and title with the actual embed details. This defers the frame as a unit; it is distinct from controlling when a native video file is fetched. For greater control over third-party player setup, defer creating or initializing the player until it is near view. The exact player behavior depends on the embedding service.

Test whether the video is actually deferred

  1. Load the page with the video below the fold. Inspect the browser’s network activity before scrolling. A deferred media source should not be fetched simply because the page was parsed, subject to browser behavior and the presence of autoplay.
  2. Scroll the video near the viewport. Native lazy loading uses a browser-calculated distance, not an exact pixel threshold you set. With the observer version, the source is assigned when the observed element intersects.
  3. Check the preview and layout. Confirm the poster displays as expected and the reserved video space does not collapse or shift the surrounding content.
  4. Start playback. Confirm the selected source loads and plays, and that the fallback source works in the browsers you support.
  5. Repeat for relevant visitor conditions. Include JavaScript-disabled behavior if it matters to your site, and check autoplay policy and accessibility needs.

Do not use the browser’s window load event as proof that every visible lazy video is ready. MDN notes that a lazy video in the initial visual viewport may load after that event, because the event is based on eagerly loaded content.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common problems

  • The video downloads on initial page load. Check for autoplay, which can require an earlier media fetch. Check that the media source is actually on the video or source element, rather than assuming preload="none" is an absolute block; preload is a browser hint.
  • The video takes too long to appear or play. Lazy loading deliberately postpones work. Check that the visitor can see a poster and that the media URL is valid and reachable. If the content should be ready sooner, reconsider whether that video belongs in the initial viewport or whether a different preload choice is appropriate.
  • The page jumps when the video appears. Set explicit dimensions or reserve space with an aspect ratio. A lazy video without known dimensions may initially occupy no space.
  • The poster is missing. Verify the poster path and that the image can be retrieved. Remember that the poster is also deferred when paired with native lazy loading, so it need not appear while the video remains far off-screen.
  • The IntersectionObserver version never loads the media. Confirm that the script runs after the video elements exist, that the selector matches them, and that each source has a correctly spelled data-src. Check the browser console for script errors and verify that JavaScript is enabled.
  • A third-party embed still loads its player resources. The embed is an iframe/player problem, not a native video problem. Defer the iframe or postpone player initialization.

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server for developers. It can help capture a rendered page for visual checks, but it does not implement lazy loading in your site; use the HTML and JavaScript patterns above for that. One GET request can return a screenshot or PDF. For example, capture a page as WebP:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

See the ScreenshotNeo documentation for request details. Before a capture, it accepts cookie/consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf for AI agents and MCP clients. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Learn about ScreenshotNeo, or sign up for 1,000 free screenshots a month with no card.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Further reading

Frequently Asked Questions

Does loading="lazy" have a fixed distance threshold?

No fixed distance is specified in the guidance here; the browser calculates when the video is near enough to load.

Will lazy loading work if JavaScript is disabled?

No. Browser-level lazy loading is deferred only when JavaScript is enabled.

How common is autoplay on web videos?

web.dev reports an HTTP Archive figure of 20% of videos across the web including the autoplay attribute; the page labels this as a 2025/2026 edition figure.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.