Skip to content
← Tips

Isolate component previews in lazy iframes

Global CSS from copied snippets can't leak, and off-screen previews cost nothing.

  • performance
  • html
  • iframe

Snippets from Uiverse style global selectors — .card, .button, even body. Rendering dozens of them on one page would make them fight. Each preview here is a tiny static page (/embed/<category>/<name>.html) shown in an <iframe>:

<iframe src="/embed/buttons/x.html" loading="lazy" sandbox="allow-scripts allow-same-origin"></iframe>
esc