Skip to content

Commit

Permalink
wip(perf): test fully deferring initial js bundles
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyAghion committed Dec 13, 2024
1 parent 2c8bb54 commit fc5f892
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 9 deletions.
4 changes: 0 additions & 4 deletions src/Server/middleware/linkHeadersMiddleware.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { NextFunction } from "express"
import type { ArtsyRequest, ArtsyResponse } from "./artsyExpress"
import { CDN_URL, GEMINI_CLOUDFRONT_URL, WEBFONT_URL } from "Server/config"
import { getWebpackEarlyHints } from "Server/getWebpackEarlyHints"

/**
* Link headers allow 103: Early Hints to be sent to the client (by Cloudflare).
Expand All @@ -13,8 +12,6 @@ export function linkHeadersMiddleware(
res: ArtsyResponse,
next: NextFunction
) {
const { linkHeaders } = getWebpackEarlyHints()

if (!res.headersSent) {
res.header("Link", [
`<${CDN_URL}>; rel=preconnect; crossorigin`,
Expand All @@ -24,7 +21,6 @@ export function linkHeadersMiddleware(
`<${WEBFONT_URL}/ll-unica77_regular.woff2>; rel=preload; as=font; crossorigin`,
`<${WEBFONT_URL}/ll-unica77_medium.woff2>; rel=preload; as=font; crossorigin`,
`<${WEBFONT_URL}/ll-unica77_italic.woff2>; rel=preload; as=font; crossorigin`,
...linkHeaders,
])
}

Expand Down
2 changes: 1 addition & 1 deletion src/System/Router/Utils/collectAssets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const collectAssets = async ({
}
})()

return `<script src="${scriptUrl}"></script>`
return `<script defer src="${scriptUrl}"></script>`
})

initialScripts.push(...runtimeScripts)
Expand Down
4 changes: 0 additions & 4 deletions src/System/Router/renderServerApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { loadAssetManifest } from "Server/manifest"
import { ENABLE_SSR_STREAMING } from "Server/config"
import { getENV } from "Utils/getENV"
import { ServerAppResults } from "System/Router/serverRouter"
import { getWebpackEarlyHints } from "Server/getWebpackEarlyHints"
import { RenderToStreamResult } from "System/Router/Utils/renderToStream"
import { buildHtmlTemplate, HTMLProps } from "html"

Expand Down Expand Up @@ -48,15 +47,12 @@ export const renderServerApp = ({

const scripts = extractScriptTags?.()

const { linkPreloadTags } = getWebpackEarlyHints()

const options: HTMLProps = {
cdnUrl: NODE_ENV === "production" ? (CDN_URL as string) : "",
content: {
body: html,
sharifyData: sharify.script(),
head: headTagsString,
linkPreloadTags,
scripts,
style: styleTags,
},
Expand Down

0 comments on commit fc5f892

Please sign in to comment.