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) { ...@@ -53,6 +53,10 @@ function getOptionalModernScriptVariant(path: string) {
return path return path
} }
function isLowPriority(file: string) {
return file.includes('_buildManifest')
}
/** /**
* `Document` component handles the initial `document` markup and renders only on the server side. * `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. * Commonly used for implementing server side rendering for `css-in-js` libraries.
...@@ -232,11 +236,11 @@ export class Head extends Component< ...@@ -232,11 +236,11 @@ export class Head extends Component<
// the feature is enabled. This clause will filter down to the // the feature is enabled. This clause will filter down to the
// modern variants only. // 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. // preloaded for performance reasons.
return ( return (
file.endsWith(getOptionalModernScriptVariant('.js')) && file.endsWith(getOptionalModernScriptVariant('.js')) &&
!file.includes('_buildManifest') !isLowPriority(file)
) )
}) })
: [] : []
...@@ -563,19 +567,20 @@ export class NextScript extends Component<OriginProps> { ...@@ -563,19 +567,20 @@ export class NextScript extends Component<OriginProps> {
} }
const { _devOnlyInvalidateCacheQueryString } = this.context const { _devOnlyInvalidateCacheQueryString } = this.context
return files.map((file: string) => { const normalScripts = files.filter(
// Only render .js files here file => file.endsWith('.js') && !isLowPriority(file)
if (!/\.js$/.test(file)) { )
return null const lowPriorityScripts = files.filter(
} file => file.endsWith('.js') && isLowPriority(file)
)
return [...normalScripts, ...lowPriorityScripts].map(file => {
let modernProps = {} let modernProps = {}
if (process.env.__NEXT_MODERN_BUILD) { if (process.env.__NEXT_MODERN_BUILD) {
modernProps = /\.module\.js$/.test(file) modernProps = file.endsWith('.module.js')
? { type: 'module' } ? { type: 'module' }
: { noModule: true } : { noModule: true }
} }
return ( return (
<script <script
key={file} 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