-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Create configuration option to limit data-sveltekit-fetched blobs during SSR #13363
Comments
Have you tried fetching the data in the load function without using SvelteKit's |
I ran into issues with using the native fetch for SSR due to: Using So I have resorted to an HTML transforming hook in import type { Handle } from '@sveltejs/kit';
export const handle: Handle = async ({ event, resolve }) => {
const response = await resolve(event, {
transformPageChunk: ({ html, done }) => {
if (done) {
html = html.replace(/<script.*data-sveltekit-fetched.*<\/script>/g, "");
}
return html
}
});
return response;
}; This is a bit wasteful to generate large HTML, strip inlined fetches and then re-emit the HTML, so a better option would be preferred. |
What about fetching the data in a server load function? If your server load is prerendered, the data isn't inlined into the HTML. |
I tried this, but now the data is pre-rendered into the bottom <script> under the An additional problem is that SSR is very slow. I have a page like |
That's because each page is prerendered by invoking the server
Can you share more about the large inventory file you're fetching? Is it possible to import it as an asset through Vite? |
Describe the problem
I am writing a web application that uses
adapter-static
. It involves a very large inventory file with thousands of elements. This file must be loaded before the application can work properly. Hence, I load it in the top-level+layout.ts
usingfetch
. This means all child pages will have thedata-sveltekit-fetched
script blob included inline after SSR. This makes prerendered pages very large, leading to an exported website exceeding GB in size.I am about to resort to either maintaining a private SvelteKit fork or adding a post-SSR transformation pass to strip these blobs from the final HTML as this is a blocker for achieving small pre-rendered pages.
Describe the proposed solution
Make an SvelteKit configuration option (
svelte.config.js
),+page.ts
variable, or other to prevent some or all pages from including these blobs during pre-rendering.Alternatives considered
No response
Importance
would make my life easier
Additional Information
No response
The text was updated successfully, but these errors were encountered: