Commit 788654e2 authored by Janicklas Ralph's avatar Janicklas Ralph Committed by Joe Haddad

Decrease the load priority of client _buildManifest (#9167)

* Decreasing the load priority of _buildmanifest file

* Remove buildmanifest filter in preload as its not needed anymore

* Removing test for _buildManifest.module.js

* re-add code

* re-add testing

* Re-add filtering

* add missing comment

* Adjust ordering

* reduce diff
parent 988f5d10
......@@ -53,6 +53,10 @@ function getOptionalModernScriptVariant(path: string) {
return path
}
function isLowPriority(file: string) {
return file.includes('_buildManifest')
}
/**
* `Document` component handles the initial `document` markup and renders only on the server side.
* Commonly used for implementing server side rendering for `css-in-js` libraries.
......@@ -232,11 +236,11 @@ export class Head extends Component<
// the feature is enabled. This clause will filter down to the
// modern variants only.
//
// Also filter out _buildManifest because it should not be
// Also filter out low priority files because they should not be
// preloaded for performance reasons.
return (
file.endsWith(getOptionalModernScriptVariant('.js')) &&
!file.includes('_buildManifest')
!isLowPriority(file)
)
})
: []
......@@ -563,19 +567,20 @@ export class NextScript extends Component<OriginProps> {
}
const { _devOnlyInvalidateCacheQueryString } = this.context
return files.map((file: string) => {
// Only render .js files here
if (!/\.js$/.test(file)) {
return null
}
const normalScripts = files.filter(
file => file.endsWith('.js') && !isLowPriority(file)
)
const lowPriorityScripts = files.filter(
file => file.endsWith('.js') && isLowPriority(file)
)
return [...normalScripts, ...lowPriorityScripts].map(file => {
let modernProps = {}
if (process.env.__NEXT_MODERN_BUILD) {
modernProps = /\.module\.js$/.test(file)
modernProps = file.endsWith('.module.js')
? { type: 'module' }
: { noModule: true }
}
return (
<script
key={file}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment