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

Reserve the iframe’s space, give that space an intentional background, and show a placeholder until the frame’s navigation finishes. This prevents an empty white rectangle on the parent page while the embed initializes. For a frame that starts off-screen, loading="lazy" may defer its request, but it does not provide a placeholder or guarantee a particular loading sequence.

Give the iframe a stable, styled area

An iframe with no specified height defaults to 150 CSS pixels, according to MDN’s iframe reference. Set dimensions that suit the content so the page has a deliberate area for the embed before it loads. For responsive content, use a wrapper with an aspect ratio or another layout that matches the embedded document.

Style the wrapper—not just the embedded page—with a background that fits your design. A parent-page background remains under your control even when the frame comes from another site.

Example: reserved space with a loading message

This example keeps the iframe in the layout and places a status message over it. When the iframe fires its load event, JavaScript removes the message.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<div class="embed">
  <iframe
    src="https://example.com/document"
    title="Embedded document"
    loading="eager"
    onload="this.parentElement.classList.add('is-loaded')">
  </iframe>
  <p class="embed__status" role="status">Loading embedded document…</p>
</div>

<style>
  .embed {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #f1f3f5;
    overflow: hidden;
  }

  .embed iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
  }

  .embed__status {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    margin: 0;
    background: #f1f3f5;
  }

  .embed.is-loaded .embed__status {
    display: none;
  }
</style>

Replace the example URL and aspect ratio with values appropriate for your embed. The load event indicates that the iframe navigation completed; it does not prove that a web app inside the frame has finished its own initialization. If the embed needs to signal application-level readiness, use a readiness mechanism agreed with its provider rather than treating load as proof.

Choose eager or lazy loading based on when the embed is needed

Iframe loading is eager by default. With loading="lazy", the browser may defer loading a frame that is outside the visual viewport, using a distance it calculates itself. The exact threshold and timing are browser-controlled, not a fixed distance you can rely on. See MDN’s lazy-loading guide and the HTMLIFrameElement loading reference.

Choice Use when What to expect
loading="eager" or omit loading The embed is immediately visible or central to the page. The browser does not intentionally defer the iframe as a lazy-loaded off-screen frame. A placeholder may still be useful while it initializes.
loading="lazy" The iframe starts below the fold and can wait until it is near the visual viewport. The browser may delay the request. Lazy loading does not style the iframe or eliminate every intermediate blank state.

MDN documents the attribute as a loading hint; it does not promise a particular trigger distance or load time. Use the iframe reference when choosing the attribute and do not use lazy loading for content that must be available immediately.

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

Use a parent-side placeholder for third-party frames

If the iframe is cross-origin, your page cannot directly change the embedded document’s HTML or CSS. When the flash comes from the embed’s own initial background, the provider must change its document to fix that internal appearance. Otherwise, a parent-side background or placeholder can cover the reserved frame area while navigation is underway. A practical overview of this presentation approach is available from Position Is Everything.

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

Keep the iframe’s descriptive title and the placeholder’s status context. If you hide or replace the frame while it loads, make sure the placeholder does not become a permanent dead end: provide a useful fallback or link if the external service is unavailable. Browser iframe events have security and privacy constraints, so do not treat a missing or received event as a general-purpose error or success test.

Troubleshoot a flash that remains

  • The whole area disappears or shifts: set a width and height, or reserve space with a wrapper’s aspect ratio.
  • The reserved area is still white: set the wrapper background explicitly and check whether the iframe itself has an opaque background.
  • The placeholder vanishes too soon: the iframe’s load event marks navigation completion, not necessarily readiness of the embedded application. Coordinate a stronger readiness signal with the provider if needed.
  • The frame is delayed unexpectedly: check whether it is lazy-loaded and whether it is initially off-screen. Browser-controlled lazy-loading distance and timing can vary.
  • The flash is inside a third-party page: the parent cannot style that cross-origin document; ask the provider to address its initial rendering or retain a parent-side treatment.

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.