Iframe or custom element: how a third-party widget should arrive on your page
Should an embedded third-party widget be an iframe, or a script that defines a custom element?
Choose an iframe when isolation matters more than integration — untrusted content, a separate origin, a hard security boundary. Choose a custom element when the widget has to behave like part of the page: inherit the layout, size to its content, participate in one focus order, and be readable by a screen reader as a single document.
Read the article