Skip to content
×

What are the risks and recommendations for using iframes?

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.

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.

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.

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.
Keep the conversation going

Join the discussion 0 comments

What are you working through? Share a question or experience and let’s find the next step.

No comments yet. Start the conversation.

Share your thoughts

← Keep exploring
LET’S TALK

Start with your brand.

Tell me about your website and what you want to achieve.

WhatsApp tony@procrustes.info
Scan to chat on WhatsApp