perf(nuxt): render css/inline css higher than resource hints (#21793)

This commit is contained in:
Daniel Roe 2023-07-31 12:11:18 +01:00 committed by GitHub
parent 40fdff8b68
commit dad633b658
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -326,16 +326,25 @@ export default defineRenderHandler(async (event): Promise<Partial<RenderResponse
})
}
// 2. Styles
head.push({
link: Object.values(styles)
.map(resource =>
({ rel: 'stylesheet', href: renderer.rendererContext.buildAssetsURL(resource.file) })
),
style: inlinedStyles
})
if (!NO_SCRIPTS) {
// 2. Resource Hints
// @todo add priorities based on Capo
// 3. Resource Hints
// TODO: add priorities based on Capo
head.push({
link: getPreloadLinks(ssrContext, renderer.rendererContext) as Link[]
})
head.push({
link: getPrefetchLinks(ssrContext, renderer.rendererContext) as Link[]
})
// 3. Payloads
// 4. Payloads
head.push({
script: _PAYLOAD_EXTRACTION
? process.env.NUXT_JSON_PAYLOADS
@ -351,16 +360,7 @@ export default defineRenderHandler(async (event): Promise<Partial<RenderResponse
})
}
// 4. Styles
head.push({
link: Object.values(styles)
.map(resource =>
({ rel: 'stylesheet', href: renderer.rendererContext.buildAssetsURL(resource.file) })
),
style: inlinedStyles
})
// 4. Scripts
// 5. Scripts
if (!routeOptions.experimentalNoScripts) {
head.push({
script: Object.values(scripts).map(resource => (<Script> {