fix(next/head): assign bool attrs to match server#20748
Merged
kodiakhq[bot] merged 2 commits intovercel:canaryfrom Jan 4, 2021
Merged
fix(next/head): assign bool attrs to match server#20748kodiakhq[bot] merged 2 commits intovercel:canaryfrom
kodiakhq[bot] merged 2 commits intovercel:canaryfrom
Conversation
This pull request correctly assigns boolean attributes for `<script />` to match the element as it is created by a server-side render. Prior to this pull request, we'd double-execute `<script>` tags with the `async`, `defer`, or `nomodule` property. --- Fixes vercel#9070
Member
Stats from current PRDefault Server Mode (Increase detected
|
| vercel/next.js canary | Timer/next.js hotfix/boolean-attributes | Change | |
|---|---|---|---|
| buildDuration | 8.7s | 8.9s | |
| nodeModulesSize | 80.6 MB | 80.6 MB |
Page Load Tests Overall decrease ⚠️
| vercel/next.js canary | Timer/next.js hotfix/boolean-attributes | Change | |
|---|---|---|---|
| / failed reqs | 0 | 0 | ✓ |
| / total time (seconds) | 1.739 | 1.753 | |
| / avg req/sec | 1437.69 | 1426.26 | |
| /error-in-render failed reqs | 0 | 0 | ✓ |
| /error-in-render total time (seconds) | 1.068 | 1.08 | |
| /error-in-render avg req/sec | 2339.94 | 2315.77 |
Client Bundles (main, webpack, commons) Overall increase ⚠️
| vercel/next.js canary | Timer/next.js hotfix/boolean-attributes | Change | |
|---|---|---|---|
| 677f882d2ed8..396f.js gzip | 13 kB | 13 kB | ✓ |
| framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
| main-fd59cc5..1b57.js gzip | 6.59 kB | 6.63 kB | |
| webpack-50be..df5b.js gzip | 751 B | 751 B | ✓ |
| Overall change | 59.3 kB | 59.3 kB |
Legacy Client Bundles (polyfills)
| vercel/next.js canary | Timer/next.js hotfix/boolean-attributes | Change | |
|---|---|---|---|
| polyfills-81..14d7.js gzip | 31.2 kB | 31.2 kB | ✓ |
| Overall change | 31.2 kB | 31.2 kB | ✓ |
Client Pages
| vercel/next.js canary | Timer/next.js hotfix/boolean-attributes | Change | |
|---|---|---|---|
| _app-b6fc6bc..222c.js gzip | 1.28 kB | 1.28 kB | ✓ |
| _error-e2ffa..0f3f.js gzip | 3.46 kB | 3.46 kB | ✓ |
| hooks-010c20..8411.js gzip | 887 B | 887 B | ✓ |
| index-bbee2f..528b.js gzip | 227 B | 227 B | ✓ |
| link-705099c..c35d.js gzip | 1.64 kB | 1.64 kB | ✓ |
| routerDirect..bf84.js gzip | 303 B | 303 B | ✓ |
| withRouter-a..5826.js gzip | 302 B | 302 B | ✓ |
| Overall change | 8.09 kB | 8.09 kB | ✓ |
Client Build Manifests
| vercel/next.js canary | Timer/next.js hotfix/boolean-attributes | Change | |
|---|---|---|---|
| _buildManifest.js gzip | 323 B | 323 B | ✓ |
| Overall change | 323 B | 323 B | ✓ |
Rendered Page Sizes Overall increase ⚠️
| vercel/next.js canary | Timer/next.js hotfix/boolean-attributes | Change | |
|---|---|---|---|
| index.html gzip | 613 B | 615 B | |
| link.html gzip | 619 B | 620 B | |
| withRouter.html gzip | 607 B | 608 B | |
| Overall change | 1.84 kB | 1.84 kB |
Diffs
Diff for main-c812617..62dbb6f36.js
@@ -93,7 +93,8 @@ _N_E = (window["webpackJsonp_N_E"] = window["webpackJsonp_N_E"] || []).push([
acceptCharset: "accept-charset",
className: "class",
htmlFor: "for",
- httpEquiv: "http-equiv"
+ httpEquiv: "http-equiv",
+ noModule: "noModule"
};
exports.DOMAttributeNames = DOMAttributeNames;
@@ -108,7 +109,15 @@ _N_E = (window["webpackJsonp_N_E"] = window["webpackJsonp_N_E"] || []).push([
if (props[p] === undefined) continue;
var attr = DOMAttributeNames[p] || p.toLowerCase();
- el.setAttribute(attr, props[p]);
+
+ if (
+ type === "script" &&
+ (attr === "async" || attr === "defer" || attr === "noModule")
+ ) {
+ el[attr] = !!props[p];
+ } else {
+ el.setAttribute(attr, props[p]);
+ }
}
var children = props.children,Diff for index.html
@@ -7,7 +7,7 @@
<noscript data-n-css=""></noscript>
<link
rel="preload"
- href="/_next/static/chunks/main-c812617d01862dbb6f36.js"
+ href="/_next/static/chunks/main-c371cf8cfc0efe26c758.js"
as="script"
/>
<link
@@ -53,7 +53,7 @@
src="/_next/static/chunks/polyfills-ae47a1f95297af5f55f8.js"
></script>
<script
- src="/_next/static/chunks/main-c812617d01862dbb6f36.js"
+ src="/_next/static/chunks/main-c371cf8cfc0efe26c758.js"
async=""
></script>
<scriptDiff for link.html
@@ -7,7 +7,7 @@
<noscript data-n-css=""></noscript>
<link
rel="preload"
- href="/_next/static/chunks/main-c812617d01862dbb6f36.js"
+ href="/_next/static/chunks/main-c371cf8cfc0efe26c758.js"
as="script"
/>
<link
@@ -58,7 +58,7 @@
src="/_next/static/chunks/polyfills-ae47a1f95297af5f55f8.js"
></script>
<script
- src="/_next/static/chunks/main-c812617d01862dbb6f36.js"
+ src="/_next/static/chunks/main-c371cf8cfc0efe26c758.js"
async=""
></script>
<scriptDiff for withRouter.html
@@ -7,7 +7,7 @@
<noscript data-n-css=""></noscript>
<link
rel="preload"
- href="/_next/static/chunks/main-c812617d01862dbb6f36.js"
+ href="/_next/static/chunks/main-c371cf8cfc0efe26c758.js"
as="script"
/>
<link
@@ -53,7 +53,7 @@
src="/_next/static/chunks/polyfills-ae47a1f95297af5f55f8.js"
></script>
<script
- src="/_next/static/chunks/main-c812617d01862dbb6f36.js"
+ src="/_next/static/chunks/main-c371cf8cfc0efe26c758.js"
async=""
></script>
<scriptServerless Mode (Increase detected ⚠️ )
General Overall increase ⚠️
| vercel/next.js canary | Timer/next.js hotfix/boolean-attributes | Change | |
|---|---|---|---|
| buildDuration | 10.7s | 10.5s | -203ms |
| nodeModulesSize | 80.6 MB | 80.6 MB |
Client Bundles (main, webpack, commons) Overall increase ⚠️
| vercel/next.js canary | Timer/next.js hotfix/boolean-attributes | Change | |
|---|---|---|---|
| 677f882d2ed8..396f.js gzip | 13 kB | 13 kB | ✓ |
| framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
| main-fd59cc5..1b57.js gzip | 6.59 kB | N/A | N/A |
| webpack-50be..df5b.js gzip | 751 B | 751 B | ✓ |
| main-6b712d3..3360.js gzip | N/A | 6.63 kB | N/A |
| Overall change | 59.3 kB | 59.3 kB |
Legacy Client Bundles (polyfills)
| vercel/next.js canary | Timer/next.js hotfix/boolean-attributes | Change | |
|---|---|---|---|
| polyfills-81..14d7.js gzip | 31.2 kB | 31.2 kB | ✓ |
| Overall change | 31.2 kB | 31.2 kB | ✓ |
Client Pages
| vercel/next.js canary | Timer/next.js hotfix/boolean-attributes | Change | |
|---|---|---|---|
| _app-b6fc6bc..222c.js gzip | 1.28 kB | 1.28 kB | ✓ |
| _error-e2ffa..0f3f.js gzip | 3.46 kB | 3.46 kB | ✓ |
| hooks-010c20..8411.js gzip | 887 B | 887 B | ✓ |
| index-bbee2f..528b.js gzip | 227 B | 227 B | ✓ |
| link-705099c..c35d.js gzip | 1.64 kB | 1.64 kB | ✓ |
| routerDirect..bf84.js gzip | 303 B | 303 B | ✓ |
| withRouter-a..5826.js gzip | 302 B | 302 B | ✓ |
| Overall change | 8.09 kB | 8.09 kB | ✓ |
Client Build Manifests
| vercel/next.js canary | Timer/next.js hotfix/boolean-attributes | Change | |
|---|---|---|---|
| _buildManifest.js gzip | 323 B | 323 B | ✓ |
| Overall change | 323 B | 323 B | ✓ |
Serverless bundles
| vercel/next.js canary | Timer/next.js hotfix/boolean-attributes | Change | |
|---|---|---|---|
| _error.js | 1 MB | 1 MB | ✓ |
| 404.html | 2.67 kB | 2.67 kB | ✓ |
| hooks.html | 1.92 kB | 1.92 kB | ✓ |
| index.js | 1 MB | 1 MB | ✓ |
| link.js | 1.06 MB | 1.06 MB | ✓ |
| routerDirect.js | 1.05 MB | 1.05 MB | ✓ |
| withRouter.js | 1.05 MB | 1.05 MB | ✓ |
| Overall change | 5.17 MB | 5.17 MB | ✓ |
ijjk
approved these changes
Jan 4, 2021
Member
Stats from current PRDefault Server Mode (Increase detected
|
| vercel/next.js canary | Timer/next.js hotfix/boolean-attributes | Change | |
|---|---|---|---|
| buildDuration | 10.2s | 10.2s | |
| nodeModulesSize | 80.6 MB | 80.6 MB |
Page Load Tests Overall increase ✓
| vercel/next.js canary | Timer/next.js hotfix/boolean-attributes | Change | |
|---|---|---|---|
| / failed reqs | 0 | 0 | ✓ |
| / total time (seconds) | 2.039 | 2.024 | -0.02 |
| / avg req/sec | 1225.83 | 1235.48 | +9.65 |
| /error-in-render failed reqs | 0 | 0 | ✓ |
| /error-in-render total time (seconds) | 1.276 | 1.212 | -0.06 |
| /error-in-render avg req/sec | 1958.58 | 2062.77 | +104.19 |
Client Bundles (main, webpack, commons) Overall increase ⚠️
| vercel/next.js canary | Timer/next.js hotfix/boolean-attributes | Change | |
|---|---|---|---|
| 677f882d2ed8..396f.js gzip | 13 kB | 13 kB | ✓ |
| framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
| main-fd59cc5..1b57.js gzip | 6.59 kB | 6.63 kB | |
| webpack-50be..df5b.js gzip | 751 B | 751 B | ✓ |
| Overall change | 59.3 kB | 59.3 kB |
Legacy Client Bundles (polyfills)
| vercel/next.js canary | Timer/next.js hotfix/boolean-attributes | Change | |
|---|---|---|---|
| polyfills-81..14d7.js gzip | 31.2 kB | 31.2 kB | ✓ |
| Overall change | 31.2 kB | 31.2 kB | ✓ |
Client Pages
| vercel/next.js canary | Timer/next.js hotfix/boolean-attributes | Change | |
|---|---|---|---|
| _app-b6fc6bc..222c.js gzip | 1.28 kB | 1.28 kB | ✓ |
| _error-e2ffa..0f3f.js gzip | 3.46 kB | 3.46 kB | ✓ |
| hooks-010c20..8411.js gzip | 887 B | 887 B | ✓ |
| index-bbee2f..528b.js gzip | 227 B | 227 B | ✓ |
| link-705099c..c35d.js gzip | 1.64 kB | 1.64 kB | ✓ |
| routerDirect..bf84.js gzip | 303 B | 303 B | ✓ |
| withRouter-a..5826.js gzip | 302 B | 302 B | ✓ |
| Overall change | 8.09 kB | 8.09 kB | ✓ |
Client Build Manifests
| vercel/next.js canary | Timer/next.js hotfix/boolean-attributes | Change | |
|---|---|---|---|
| _buildManifest.js gzip | 323 B | 323 B | ✓ |
| Overall change | 323 B | 323 B | ✓ |
Rendered Page Sizes Overall increase ⚠️
| vercel/next.js canary | Timer/next.js hotfix/boolean-attributes | Change | |
|---|---|---|---|
| index.html gzip | 613 B | 615 B | |
| link.html gzip | 619 B | 620 B | |
| withRouter.html gzip | 607 B | 608 B | |
| Overall change | 1.84 kB | 1.84 kB |
Diffs
Diff for main-c812617..62dbb6f36.js
@@ -93,7 +93,8 @@ _N_E = (window["webpackJsonp_N_E"] = window["webpackJsonp_N_E"] || []).push([
acceptCharset: "accept-charset",
className: "class",
htmlFor: "for",
- httpEquiv: "http-equiv"
+ httpEquiv: "http-equiv",
+ noModule: "noModule"
};
exports.DOMAttributeNames = DOMAttributeNames;
@@ -108,7 +109,15 @@ _N_E = (window["webpackJsonp_N_E"] = window["webpackJsonp_N_E"] || []).push([
if (props[p] === undefined) continue;
var attr = DOMAttributeNames[p] || p.toLowerCase();
- el.setAttribute(attr, props[p]);
+
+ if (
+ type === "script" &&
+ (attr === "async" || attr === "defer" || attr === "noModule")
+ ) {
+ el[attr] = !!props[p];
+ } else {
+ el.setAttribute(attr, props[p]);
+ }
}
var children = props.children,Diff for index.html
@@ -7,7 +7,7 @@
<noscript data-n-css=""></noscript>
<link
rel="preload"
- href="/_next/static/chunks/main-c812617d01862dbb6f36.js"
+ href="/_next/static/chunks/main-c371cf8cfc0efe26c758.js"
as="script"
/>
<link
@@ -53,7 +53,7 @@
src="/_next/static/chunks/polyfills-ae47a1f95297af5f55f8.js"
></script>
<script
- src="/_next/static/chunks/main-c812617d01862dbb6f36.js"
+ src="/_next/static/chunks/main-c371cf8cfc0efe26c758.js"
async=""
></script>
<scriptDiff for link.html
@@ -7,7 +7,7 @@
<noscript data-n-css=""></noscript>
<link
rel="preload"
- href="/_next/static/chunks/main-c812617d01862dbb6f36.js"
+ href="/_next/static/chunks/main-c371cf8cfc0efe26c758.js"
as="script"
/>
<link
@@ -58,7 +58,7 @@
src="/_next/static/chunks/polyfills-ae47a1f95297af5f55f8.js"
></script>
<script
- src="/_next/static/chunks/main-c812617d01862dbb6f36.js"
+ src="/_next/static/chunks/main-c371cf8cfc0efe26c758.js"
async=""
></script>
<scriptDiff for withRouter.html
@@ -7,7 +7,7 @@
<noscript data-n-css=""></noscript>
<link
rel="preload"
- href="/_next/static/chunks/main-c812617d01862dbb6f36.js"
+ href="/_next/static/chunks/main-c371cf8cfc0efe26c758.js"
as="script"
/>
<link
@@ -53,7 +53,7 @@
src="/_next/static/chunks/polyfills-ae47a1f95297af5f55f8.js"
></script>
<script
- src="/_next/static/chunks/main-c812617d01862dbb6f36.js"
+ src="/_next/static/chunks/main-c371cf8cfc0efe26c758.js"
async=""
></script>
<scriptServerless Mode (Increase detected ⚠️ )
General Overall increase ⚠️
| vercel/next.js canary | Timer/next.js hotfix/boolean-attributes | Change | |
|---|---|---|---|
| buildDuration | 12.7s | 12.5s | -214ms |
| nodeModulesSize | 80.6 MB | 80.6 MB |
Client Bundles (main, webpack, commons) Overall increase ⚠️
| vercel/next.js canary | Timer/next.js hotfix/boolean-attributes | Change | |
|---|---|---|---|
| 677f882d2ed8..396f.js gzip | 13 kB | 13 kB | ✓ |
| framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
| main-fd59cc5..1b57.js gzip | 6.59 kB | N/A | N/A |
| webpack-50be..df5b.js gzip | 751 B | 751 B | ✓ |
| main-6b712d3..3360.js gzip | N/A | 6.63 kB | N/A |
| Overall change | 59.3 kB | 59.3 kB |
Legacy Client Bundles (polyfills)
| vercel/next.js canary | Timer/next.js hotfix/boolean-attributes | Change | |
|---|---|---|---|
| polyfills-81..14d7.js gzip | 31.2 kB | 31.2 kB | ✓ |
| Overall change | 31.2 kB | 31.2 kB | ✓ |
Client Pages
| vercel/next.js canary | Timer/next.js hotfix/boolean-attributes | Change | |
|---|---|---|---|
| _app-b6fc6bc..222c.js gzip | 1.28 kB | 1.28 kB | ✓ |
| _error-e2ffa..0f3f.js gzip | 3.46 kB | 3.46 kB | ✓ |
| hooks-010c20..8411.js gzip | 887 B | 887 B | ✓ |
| index-bbee2f..528b.js gzip | 227 B | 227 B | ✓ |
| link-705099c..c35d.js gzip | 1.64 kB | 1.64 kB | ✓ |
| routerDirect..bf84.js gzip | 303 B | 303 B | ✓ |
| withRouter-a..5826.js gzip | 302 B | 302 B | ✓ |
| Overall change | 8.09 kB | 8.09 kB | ✓ |
Client Build Manifests
| vercel/next.js canary | Timer/next.js hotfix/boolean-attributes | Change | |
|---|---|---|---|
| _buildManifest.js gzip | 323 B | 323 B | ✓ |
| Overall change | 323 B | 323 B | ✓ |
Serverless bundles
| vercel/next.js canary | Timer/next.js hotfix/boolean-attributes | Change | |
|---|---|---|---|
| _error.js | 1 MB | 1 MB | ✓ |
| 404.html | 2.67 kB | 2.67 kB | ✓ |
| hooks.html | 1.92 kB | 1.92 kB | ✓ |
| index.js | 1 MB | 1 MB | ✓ |
| link.js | 1.06 MB | 1.06 MB | ✓ |
| routerDirect.js | 1.05 MB | 1.05 MB | ✓ |
| withRouter.js | 1.05 MB | 1.05 MB | ✓ |
| Overall change | 5.17 MB | 5.17 MB | ✓ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request correctly assigns boolean attributes for
<script />to match the element as it is created by a server-side render.Prior to this pull request, we'd double-execute
<script>tags with theasync,defer, ornomoduleproperty.Fixes #9070