What are the risks and recommendations for using iframes?

ProcrustesPR

iframes can embed videos, maps, documents, or third-party applications, but whether they are appropriate depends on the trustworthiness of the source, the purpose of the content, and how it loads. The main risks include security issues from untrusted content, slower pages due to additional loading, and layout shifts when space is not reserved. Embed only content with a clear purpose, consider using sandbox to restrict functionality, and set dimensions. Also, do not treat embedding content from other websites as a way to directly improve your site’s rankings.

ProcrustesPRProcrustesPRDoes my website need a speed score of 100?

Consider source trustworthiness and functional restrictions together

Neil Patel’s 2023 article uses the example of a malicious iframe redirecting users to a fake login page to explain how users could be tricked into giving away their credentials. This is a risk scenario, not a claim that every iframe steals data. What matters is who provides the content and what the embedded content can do.

  • Prioritize trusted sources: Check whether the provider is reliable, and avoid embedding content from unknown sources indiscriminately.
  • Consider enabling sandbox: This attribute can restrict iframe functionality and reduce risk, but it should not be treated as a security guarantee.
  • Ensure the content is relevant to the page: For example, placing a map on a page with travel directions serves a clearer purpose than adding an external component unrelated to the topic.

Loading speed and layout shifts are two different issues

Semrush’s 2024 article notes that embedding an iframe means the page also has to load content from another website, which may increase waiting time. Remove unnecessary embeds first, rather than adding every external component simply because it is easy to do so.

Another issue is space allocation. iframes, ads, or other embedded content without specified dimensions may push existing text aside as they load. Even if the wait is acceptable, a sudden change in reading position can still disrupt the experience. Set dimensions and reserve layout space during implementation. Third-party ad sizes may be harder to control, making this limitation especially important to keep in mind.

Do not confuse indexability with ranking benefits for your site

The supplied articles disagree on indexing: Semrush’s 2024 article states that content within iframes is not indexed by search engines, while Neil Patel’s 2023 article says search engines can crawl and index it. These materials do not support the conclusion that iframe content can never be indexed.

As for rankings, Semrush says external iframe content is treated as belonging to another website and therefore does not directly help your site’s rankings. This is separate from whether the content can be indexed, and it does not imply that simply using an iframe will lower your rankings.

Choose alternatives based on your needs, rather than switching everything to JavaScript

If you need dynamic loading, content updates, or more control, JavaScript is an option to consider. However, Neil Patel also cautions that it is more complex to implement and that its behavior may vary across browsers. Evaluate your website platform, content type, visitors’ devices and browsers, and intended goals together. An approach is not necessarily more suitable simply because it avoids iframes.

ProcrustesPRProcrustesPREight SEO essentials for beginners: Website speed

Using iframes: perspectives from across the web

What if I do not want a media page indexed directly, but want its embedded content indexed?

An older Semrush article describes using noindex together with indexifembedded for situations where you do not want a media page indexed directly, but want Google to be able to index its content when it is embedded in other pages through an iframe. The article also cautions that not all search engines support this. The supplied materials are insufficient to confirm the rules that currently apply.

Is AJAX always better than an iframe for embedding content?

Not necessarily. Neil Patel's 2023 article suggests that AJAX is generally faster and easier to crawl, while iframes are easier to implement and support a wider range of browsers and devices. This is a broad comparison from the article, not a guarantee of the same results for every website. Your choice should still take into account the embedded content, website platform, visitors' browsers and devices, and intended goals.

ProcrustesPRWhat Ten Years of SEO Taught Me About Its Real Purpose

References

  1. Ultimate Guide to iFrame SEOneilpatel.com · 2023-09-12T19:00:00+00:00 — Discusses: Is AJAX always better than an iframe for embedding content?
  2. 12 SEO HTML Tags You Need to Knowwww.semrush.com · 2024-05-07T13:23:00Z — Source used in the article above.
  3. Meta Robots Tag & X-Robots-Tag Explainedwww.semrush.com · 2020-12-16T14:16:00Z — Discusses: What if I do not want a media page indexed directly, but want its embedded content indexed?
  4. Cumulative Layout Shift: What It Is & How to Improve Your Scorewww.semrush.com · 2024-04-26T09:59:00Z — Source used in the article above.

Related articles

Does my website need a speed score of 100?Eight SEO essentials for beginners: Website speedWhat Ten Years of SEO Taught Me About Its Real PurposeHow Do RWD and AWD Work, and Which Should You Choose for Your Website?What are the benefits and development challenges of SPAs?How do UTF-8 and Big5 differ in their effects on search rankings and user experience?What are single-page websites best suited for, and what are their pros and cons?Keep different topics on one site or split them up? Start with audience overlap and maintenance capacity
ProcrustesPR
ProcrustesPR