1.19 Minimize iframes

Each one is a second page, with a second everything.

Minimize number of iframes

An iframe loads a whole separate document, with its own HTML, CSS, JavaScript and network connections. A page with three embedded widgets is really four pages, and the browser pays for all of them.

They also compete for the main thread. A heavy third-party embed — a video player, a chat widget, a map — can block interaction on your page while it boots.

Beyond performance, iframes complicate keyboard navigation and focus order, and their content is invisible to your own analytics and to search indexing.

When you still need one

Sandboxing untrusted content and embedding a third-party player are both legitimate. When you do:

Load it lazily. This alone removes the cost for anything below the fold:

<iframe src="https://example.com/player" loading="lazy" title="Product demo"></iframe>

Give it a title. Screen readers announce it; without one the frame is an unlabelled region.

Consider a facade. Render a lightweight placeholder — a thumbnail with a play button — and load the real embed on click. For a YouTube video this turns roughly 1MB of player JavaScript into an image.

On this page