From d64a76eb366a270c56189096a5e0ae6b8ae23ea7 Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 13 Mar 2023 13:40:12 +0800 Subject: [PATCH] perf: kickoff main chunk fetch earlier in browsers without modulepreload support --- src/node/build/render.ts | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/node/build/render.ts b/src/node/build/render.ts index 15fdcce9..84986624 100644 --- a/src/node/build/render.ts +++ b/src/node/build/render.ts @@ -65,9 +65,7 @@ export async function renderPage( let preloadLinks = config.mpa || (!hasCustom404 && page === '404.md') - ? appChunk - ? [appChunk.fileName] - : [] + ? [] : result && appChunk ? [ ...new Set([ @@ -75,8 +73,7 @@ export async function renderPage( // for them as well so we fetch everything as early as possible // without having to wait for entry chunks to parse ...resolvePageImports(config, page, result, appChunk), - pageClientJsFileName, - appChunk.fileName + pageClientJsFileName ]) ] : [] @@ -163,6 +160,11 @@ export async function renderPage( ${title} ${stylesheetLink} + ${ + appChunk + ? `` + : `` + } ${preloadLinksString} ${prefetchLinkString} ${await renderHead(head)} @@ -170,11 +172,6 @@ export async function renderPage( ${teleports?.body || ''}
${content}
${config.mpa ? '' : ``} - ${ - appChunk - ? `` - : `` - } ${inlinedScript} `.trim()