Developer Learns Iframes Beat Web Components for Embedding Full Apps After Three Weeks
A developer building SEO landing pages for a web tool attempted to use a custom Web Component to inject canonical app HTML into wrapper pages, aiming to deduplicate code while preserving per-page metadata. The approach silently broke the app because swapping document.body.innerHTML destroyed the original DOM after event handlers had already attached to it, causing non-deterministic behavior where the UI appeared functional but produced no output. The bug went undetected for weeks because the canonical URL used for testing bypassed the wrapper path that real users encountered. The fix mirrored a pattern already used in the project's VS Code extension: embedding the canonical app in a full-viewport iframe, letting it initialize against its own DOM without interference. The key takeaway is that Web Components suit UI elements rendered within a host document, while fully initialized apps with their own lifecycle require browser-native isolation like iframes.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in