Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iframes reload from source #14

Open
evanfrawley opened this issue Aug 13, 2020 · 7 comments
Open

iframes reload from source #14

evanfrawley opened this issue Aug 13, 2020 · 7 comments

Comments

@evanfrawley
Copy link

Hi! Really cool library, thanks for building it.

I've found though that if I use an iframe to render an embedded video, changing the parent will reload the embed from source each time. The actual source URL of the iframe doesn't matter. Do you have any idea why this might be the case?

@pimterry
Copy link
Member

Unfortunately, this isn't a limitation of reverse portals, this is a limitation of the DOM itself: https://stackoverflow.com/a/8318401/68051.

As far as I can tell, the iframe is being moved around the DOM totally correctly, so the DOM node in the new location is the same as the old one, but iframes have unique behaviour where they reload every time they're moved in any way.

This isn't likely to be fixable, as its core browser behaviour, so the only way to move an iframe around the page without reloading is with CSS. Sorry about that! If you do find any ways to do this I'd love to hear about them. For now though, I'm going to assume this is impossible, so I'll close this issue.

@evanfrawley
Copy link
Author

Thanks @pimterry for your insightful reply :) I'll keep poking around and see if I figure out something

@wyhinton
Copy link

@evanfrawley did you discover anything? Struggling with getting my iframes not to reload currently.

@evanfrawley
Copy link
Author

@wyhinton nope, we just didn't go down this road anymore

@ryanhartwig
Copy link

@pimterry This is something that could definitely be included in the Important notes section of the documentation. I've spent about half a day setting up and trying to determine why this isn't working using an iframe.

@pimterry
Copy link
Member

pimterry commented May 6, 2024

@ryanhartwig sure, good idea, I'd accept a PR for that if you're interested

@pimterry
Copy link
Member

pimterry commented Feb 5, 2025

Chrome 133 (released yesterday) has a solution for this iframe problem! I'll reopen this issue now.

They've introduced a new moveBefore API that explicitly doesn't reload iframes: https://chromestatus.com/feature/5135990159835136. If we detect and use that when available then this problem will go away entirely.

PRs welcome if somebody has a minute to set this up and test it works as expected in Chrome 133. Looks like Safari & Firefox have shared positive signals on implementing this too, so eventually this will go away everywhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants