-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Fix hydration on slow connection #8680
Conversation
🦋 Changeset detectedLatest commit: 33a019c The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Actually I need to benchmark multiple islands too to confirm it doesn’t stall them altogether. Marking as draft. |
I did some tests, it actually stalled all islands before rendering, which isn't a great experience for those on poor connections who have to wait for the entire page to load before they can interact with it. Update: Uses Nate's idea of a comment marker completely, and a fallback |
This is ready for review. I updated the PR description of what this PR does now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty clever solution!
Changes
Fix #8178
This implements a
<!--astro:end-->
comment marker added as the last child of theastro-island
tag, used to detect if the children is ready for hydration.As the comment marker could risk being stripped by HTML minifiers, I also added a fallback
DOMContentLoaded
listener to hydrate if it's triggered.The downside with this approach is the increased code size for the astro-island component: 3053 chars -> 3362 chars.
Testing
Tested manually with the repro in #8178. It's a bit hard to create a test for this without making it flaky.
Docs
n/a. We currently don't document at the very specific time when we start hydrating.