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