I'm currently developing a chrome extension and I've just converted to using the shadow dom for style encapsulation. Is there any benefit from using an iFrame over this?
So far what comes to mind is:
However, I think there can be more complexities and overhead by using iFrames, especially when trying to pass messages back and forth from the background script.
Thoughts?
I think your analysis is basically right: there's a tradeoff between messaging complexity vs. development iteration ergonomics.
Another benefit of iframes is that you're able to embed a separate website that can be updated at a different cadence as your web extension. There's a couple caveats though:
You can mitigate the downsides of Shadow DOM by using a package like webpack-extension-reloader to automatically reload the extension (and also any pages it's running on) on code updates.