-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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: extract shared logic for server island loading into a function and only include it once #13576
Conversation
🦋 Changeset detectedLatest commit: c297c5c 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 |
astro
@astrojs/cloudflare
@astrojs/netlify
@astrojs/node
@astrojs/vercel
commit: |
CodSpeed Performance ReportMerging #13576 will not alter performanceComparing Summary
|
I would suggest using the render instruction for this, this is how we do the same thing to only render the hydration scripts once. The advantage is that you know for sure that the script is always rendered before the usage. I know that in this case we're using module scripts, but if you ever want to change that in the future you'd want to use render instructions instead. Here's an example of the usage in hydration scripts.
|
Changes
Currently, each server island includes a script to load its own content. That includes quite a bit of logic that could be shared between islands. This PR extracts that into a function that can be reused by each island, and includes it only once. This runtime script is defined as a classic, non-module script so that we can guarantee that it has always executed before any of the module scripts runs.
Testing
Added and updated tests
Docs