-
Notifications
You must be signed in to change notification settings - Fork 26.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(next/script): Omit src for children and dangerouslySetInnerHTML props #26367
Conversation
Stats from current PRDefault Server Mode (Increase detected
|
vercel/next.js canary | prichodko/next.js fix/next-script-src-inline | Change | |
---|---|---|---|
buildDuration | 12.6s | 12.6s | -23ms |
buildDurationCached | 3.1s | 3.1s | -10ms |
nodeModulesSize | 49.2 MB | 49.2 MB |
Page Load Tests Overall increase ✓
vercel/next.js canary | prichodko/next.js fix/next-script-src-inline | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.322 | 2.268 | -0.05 |
/ avg req/sec | 1076.57 | 1102.19 | +25.62 |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.287 | 1.3 | |
/error-in-render avg req/sec | 1942.82 | 1923.74 |
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary | prichodko/next.js fix/next-script-src-inline | Change | |
---|---|---|---|
framework-HASH.js gzip | 42 kB | 42 kB | ✓ |
main-HASH.js gzip | 20.2 kB | 20.2 kB | |
webpack-HASH.js gzip | 810 B | 810 B | ✓ |
Overall change | 63 kB | 63 kB |
Legacy Client Bundles (polyfills)
vercel/next.js canary | prichodko/next.js fix/next-script-src-inline | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 31.1 kB | 31.1 kB | ✓ |
Overall change | 31.1 kB | 31.1 kB | ✓ |
Client Pages
vercel/next.js canary | prichodko/next.js fix/next-script-src-inline | Change | |
---|---|---|---|
_app-HASH.js gzip | 801 B | 801 B | ✓ |
_error-HASH.js gzip | 3.17 kB | 3.17 kB | ✓ |
amp-HASH.js gzip | 527 B | 527 B | ✓ |
css-HASH.js gzip | 330 B | 330 B | ✓ |
hooks-HASH.js gzip | 903 B | 903 B | ✓ |
index-HASH.js gzip | 263 B | 263 B | ✓ |
link-HASH.js gzip | 1.65 kB | 1.65 kB | ✓ |
routerDirect..HASH.js gzip | 322 B | 322 B | ✓ |
withRouter-HASH.js gzip | 320 B | 320 B | ✓ |
bb14e60e810b..30f.css gzip | 125 B | 125 B | ✓ |
Overall change | 8.41 kB | 8.41 kB | ✓ |
Client Build Manifests
vercel/next.js canary | prichodko/next.js fix/next-script-src-inline | Change | |
---|---|---|---|
_buildManifest.js gzip | 392 B | 392 B | ✓ |
Overall change | 392 B | 392 B | ✓ |
Rendered Page Sizes Overall increase ⚠️
vercel/next.js canary | prichodko/next.js fix/next-script-src-inline | Change | |
---|---|---|---|
index.html gzip | 523 B | 523 B | ✓ |
link.html gzip | 532 B | 534 B | |
withRouter.html gzip | 514 B | 516 B | |
Overall change | 1.57 kB | 1.57 kB |
Diffs
Diff for main-HASH.js
@@ -2999,6 +2999,10 @@
continue;
}
+ if ((dangerouslySetInnerHTML || children) && k === "src") {
+ continue;
+ }
+
var attr = _headManager.DOMAttributeNames[k] || k.toLowerCase();
el.setAttribute(attr, value);
}
Diff for index.html
@@ -19,7 +19,7 @@
defer=""
></script>
<script
- src="/_next/static/chunks/main-f7adf56f2601c8465f9f.js"
+ src="/_next/static/chunks/main-761107ed5551b8a9b6bd.js"
defer=""
></script>
<script
Diff for link.html
@@ -19,7 +19,7 @@
defer=""
></script>
<script
- src="/_next/static/chunks/main-f7adf56f2601c8465f9f.js"
+ src="/_next/static/chunks/main-761107ed5551b8a9b6bd.js"
defer=""
></script>
<script
Diff for withRouter.html
@@ -19,7 +19,7 @@
defer=""
></script>
<script
- src="/_next/static/chunks/main-f7adf56f2601c8465f9f.js"
+ src="/_next/static/chunks/main-761107ed5551b8a9b6bd.js"
defer=""
></script>
<script
Serverless Mode (Increase detected ⚠️ )
General Overall increase ⚠️
vercel/next.js canary | prichodko/next.js fix/next-script-src-inline | Change | |
---|---|---|---|
buildDuration | 14.4s | 14.3s | -121ms |
buildDurationCached | 4.2s | 4.3s | |
nodeModulesSize | 49.2 MB | 49.2 MB |
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary | prichodko/next.js fix/next-script-src-inline | Change | |
---|---|---|---|
framework-HASH.js gzip | 42 kB | 42 kB | ✓ |
main-HASH.js gzip | 20.2 kB | 20.2 kB | |
webpack-HASH.js gzip | 810 B | 810 B | ✓ |
Overall change | 63 kB | 63 kB |
Legacy Client Bundles (polyfills)
vercel/next.js canary | prichodko/next.js fix/next-script-src-inline | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 31.1 kB | 31.1 kB | ✓ |
Overall change | 31.1 kB | 31.1 kB | ✓ |
Client Pages
vercel/next.js canary | prichodko/next.js fix/next-script-src-inline | Change | |
---|---|---|---|
_app-HASH.js gzip | 801 B | 801 B | ✓ |
_error-HASH.js gzip | 3.17 kB | 3.17 kB | ✓ |
amp-HASH.js gzip | 527 B | 527 B | ✓ |
css-HASH.js gzip | 330 B | 330 B | ✓ |
hooks-HASH.js gzip | 903 B | 903 B | ✓ |
index-HASH.js gzip | 263 B | 263 B | ✓ |
link-HASH.js gzip | 1.65 kB | 1.65 kB | ✓ |
routerDirect..HASH.js gzip | 322 B | 322 B | ✓ |
withRouter-HASH.js gzip | 320 B | 320 B | ✓ |
bb14e60e810b..30f.css gzip | 125 B | 125 B | ✓ |
Overall change | 8.41 kB | 8.41 kB | ✓ |
Client Build Manifests
vercel/next.js canary | prichodko/next.js fix/next-script-src-inline | Change | |
---|---|---|---|
_buildManifest.js gzip | 392 B | 392 B | ✓ |
Overall change | 392 B | 392 B | ✓ |
Serverless bundles Overall increase ⚠️
vercel/next.js canary | prichodko/next.js fix/next-script-src-inline | Change | |
---|---|---|---|
_error.js | 16.9 kB | 16.9 kB | |
404.html | 1.98 kB | 1.98 kB | ✓ |
500.html | 1.96 kB | 1.96 kB | ✓ |
amp.amp.html | 10.8 kB | 10.8 kB | ✓ |
amp.html | 1.17 kB | 1.17 kB | ✓ |
css.html | 1.35 kB | 1.35 kB | ✓ |
hooks.html | 1.23 kB | 1.23 kB | ✓ |
index.js | 17.2 kB | 17.2 kB | ✓ |
link.js | 17.5 kB | 17.5 kB | ✓ |
routerDirect.js | 17.3 kB | 17.3 kB | ✓ |
withRouter.js | 17.3 kB | 17.3 kB | ✓ |
Overall change | 105 kB | 105 kB |
Webpack 4 Mode (Increase detected ⚠️ )
General Overall increase ⚠️
vercel/next.js canary | prichodko/next.js fix/next-script-src-inline | Change | |
---|---|---|---|
buildDuration | 11.2s | 11.3s | |
buildDurationCached | 4.7s | 4.5s | -142ms |
nodeModulesSize | 49.2 MB | 49.2 MB |
Page Load Tests Overall decrease ⚠️
vercel/next.js canary | prichodko/next.js fix/next-script-src-inline | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.281 | 2.326 | |
/ avg req/sec | 1096.16 | 1074.79 | |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.286 | 1.324 | |
/error-in-render avg req/sec | 1944.57 | 1888.86 |
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary | prichodko/next.js fix/next-script-src-inline | Change | |
---|---|---|---|
677f882d2ed8..HASH.js gzip | 13.3 kB | 13.3 kB | ✓ |
framework.HASH.js gzip | 41.8 kB | 41.8 kB | ✓ |
main-HASH.js gzip | 7.99 kB | 8 kB | |
webpack-HASH.js gzip | 757 B | 757 B | ✓ |
Overall change | 63.8 kB | 63.9 kB |
Legacy Client Bundles (polyfills)
vercel/next.js canary | prichodko/next.js fix/next-script-src-inline | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 31.3 kB | 31.3 kB | ✓ |
Overall change | 31.3 kB | 31.3 kB | ✓ |
Client Pages
vercel/next.js canary | prichodko/next.js fix/next-script-src-inline | Change | |
---|---|---|---|
_app-HASH.js gzip | 1.07 kB | 1.07 kB | ✓ |
_error-HASH.js gzip | 3.84 kB | 3.84 kB | ✓ |
amp-HASH.js gzip | 536 B | 536 B | ✓ |
css-HASH.js gzip | 333 B | 333 B | ✓ |
hooks-HASH.js gzip | 910 B | 910 B | ✓ |
index-HASH.js gzip | 227 B | 227 B | ✓ |
link-HASH.js gzip | 1.64 kB | 1.64 kB | ✓ |
routerDirect..HASH.js gzip | 295 B | 295 B | ✓ |
withRouter-HASH.js gzip | 292 B | 292 B | ✓ |
e025d2764813..52f.css gzip | 125 B | 125 B | ✓ |
Overall change | 9.28 kB | 9.28 kB | ✓ |
Client Build Manifests
vercel/next.js canary | prichodko/next.js fix/next-script-src-inline | Change | |
---|---|---|---|
_buildManifest.js gzip | 420 B | 420 B | ✓ |
Overall change | 420 B | 420 B | ✓ |
Rendered Page Sizes Overall decrease ✓
vercel/next.js canary | prichodko/next.js fix/next-script-src-inline | Change | |
---|---|---|---|
index.html gzip | 568 B | 568 B | ✓ |
link.html gzip | 581 B | 581 B | ✓ |
withRouter.html gzip | 561 B | 560 B | -1 B |
Overall change | 1.71 kB | 1.71 kB | -1 B |
Diffs
Diff for main-HASH.js
@@ -175,6 +175,10 @@ _N_E = (window["webpackJsonp_N_E"] = window["webpackJsonp_N_E"] || []).push([
continue;
}
+ if ((dangerouslySetInnerHTML || children) && k === "src") {
+ continue;
+ }
+
var attr = _headManager.DOMAttributeNames[k] || k.toLowerCase();
el.setAttribute(attr, value);
}
Diff for index.html
@@ -23,7 +23,7 @@
defer=""
></script>
<script
- src="/_next/static/chunks/main-a24959f9624e5f7ac792.js"
+ src="/_next/static/chunks/main-f23e849bcc6eff1762e6.js"
defer=""
></script>
<script
Diff for link.html
@@ -23,7 +23,7 @@
defer=""
></script>
<script
- src="/_next/static/chunks/main-a24959f9624e5f7ac792.js"
+ src="/_next/static/chunks/main-f23e849bcc6eff1762e6.js"
defer=""
></script>
<script
Diff for withRouter.html
@@ -23,7 +23,7 @@
defer=""
></script>
<script
- src="/_next/static/chunks/main-a24959f9624e5f7ac792.js"
+ src="/_next/static/chunks/main-f23e849bcc6eff1762e6.js"
defer=""
></script>
<script
Failing test suitesCommit: 13748de test/integration/build-output/test/index.test.js
Expand output● Build Output › Basic Application Output (with experimental.gzipSize: false) › should not deviate from snapshot
test/integration/basic/test/index.test.js
Expand output● Basic Features › should polyfill Node.js modules
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, this should be fixed in the latest canary of Next.js, please update and give it a try!
When using
next/script
withchildren
prop ordangerouslySetInnerHTML
together withbeforeInteractive
strategy. The DOM element is created withsrc="(unknown)"
which prevents from executing the inline script.This PR adds an explicit condition to omit
src
field in those cases.Fixes: #26343, #26240