Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
08f241fc
Commit
08f241fc
authored
Jan 17, 2020
by
Joe Haddad
Committed by
JJ Kasper
Jan 17, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch from `defer` to `async` (#10143)
parent
53d5bd89
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
9 deletions
+9
-9
_document.tsx
packages/next/pages/_document.tsx
+6
-6
index.test.js
test/integration/production/test/index.test.js
+3
-3
No files found.
packages/next/pages/_document.tsx
View file @
08f241fc
...
@@ -570,7 +570,7 @@ export class NextScript extends Component<OriginProps> {
...
@@ -570,7 +570,7 @@ export class NextScript extends Component<OriginProps> {
return
(
return
(
<
script
<
script
defer
async
key=
{
bundle
.
file
}
key=
{
bundle
.
file
}
src=
{
`${assetPrefix}/_next/${encodeURI(
src=
{
`${assetPrefix}/_next/${encodeURI(
bundle.file
bundle.file
...
@@ -611,7 +611,7 @@ export class NextScript extends Component<OriginProps> {
...
@@ -611,7 +611,7 @@ export class NextScript extends Component<OriginProps> {
file
file
)}${_devOnlyInvalidateCacheQueryString}`
}
)}${_devOnlyInvalidateCacheQueryString}`
}
nonce=
{
this
.
props
.
nonce
}
nonce=
{
this
.
props
.
nonce
}
defer
async
crossOrigin=
{
this
.
props
.
crossOrigin
||
process
.
crossOrigin
}
crossOrigin=
{
this
.
props
.
crossOrigin
||
process
.
crossOrigin
}
{
...
modernProps
}
{
...
modernProps
}
/>
/>
...
@@ -720,7 +720,7 @@ export class NextScript extends Component<OriginProps> {
...
@@ -720,7 +720,7 @@ export class NextScript extends Component<OriginProps> {
const
pageScript
=
[
const
pageScript
=
[
<
script
<
script
defer
async
data
-
next
-
page=
{
page
}
data
-
next
-
page=
{
page
}
key=
{
page
}
key=
{
page
}
src=
{
src=
{
...
@@ -734,7 +734,7 @@ export class NextScript extends Component<OriginProps> {
...
@@ -734,7 +734,7 @@ export class NextScript extends Component<OriginProps> {
/>,
/>,
process
.
env
.
__NEXT_MODERN_BUILD
&&
(
process
.
env
.
__NEXT_MODERN_BUILD
&&
(
<
script
<
script
defer
async
data
-
next
-
page=
{
page
}
data
-
next
-
page=
{
page
}
key=
{
`${page}-modern`
}
key=
{
`${page}-modern`
}
src=
{
src=
{
...
@@ -753,7 +753,7 @@ export class NextScript extends Component<OriginProps> {
...
@@ -753,7 +753,7 @@ export class NextScript extends Component<OriginProps> {
const
appScript
=
[
const
appScript
=
[
<
script
<
script
defer
async
data
-
next
-
page=
"/_app"
data
-
next
-
page=
"/_app"
src=
{
src=
{
assetPrefix
+
assetPrefix
+
...
@@ -767,7 +767,7 @@ export class NextScript extends Component<OriginProps> {
...
@@ -767,7 +767,7 @@ export class NextScript extends Component<OriginProps> {
/>,
/>,
process
.
env
.
__NEXT_MODERN_BUILD
&&
(
process
.
env
.
__NEXT_MODERN_BUILD
&&
(
<
script
<
script
defer
async
data
-
next
-
page=
"/_app"
data
-
next
-
page=
"/_app"
src=
{
src=
{
assetPrefix
+
assetPrefix
+
...
...
test/integration/production/test/index.test.js
View file @
08f241fc
...
@@ -678,13 +678,13 @@ describe('Production Usage', () => {
...
@@ -678,13 +678,13 @@ describe('Production Usage', () => {
}
}
})
})
it
(
'should have
defer
on all script tags'
,
async
()
=>
{
it
(
'should have
async
on all script tags'
,
async
()
=>
{
const
html
=
await
renderViaHTTP
(
appPort
,
'/'
)
const
html
=
await
renderViaHTTP
(
appPort
,
'/'
)
const
$
=
cheerio
.
load
(
html
)
const
$
=
cheerio
.
load
(
html
)
let
missing
=
false
let
missing
=
false
for
(
const
script
of
$
(
'script'
).
toArray
())
{
for
(
const
script
of
$
(
'script'
).
toArray
())
{
// application/json doesn't need
defer
// application/json doesn't need
async
if
(
if
(
script
.
attribs
.
type
===
'application/json'
||
script
.
attribs
.
type
===
'application/json'
||
script
.
attribs
.
src
.
includes
(
'polyfills'
)
script
.
attribs
.
src
.
includes
(
'polyfills'
)
...
@@ -692,7 +692,7 @@ describe('Production Usage', () => {
...
@@ -692,7 +692,7 @@ describe('Production Usage', () => {
continue
continue
}
}
if
(
script
.
attribs
.
async
===
''
||
script
.
attribs
.
defer
!==
''
)
{
if
(
script
.
attribs
.
defer
===
''
||
script
.
attribs
.
async
!==
''
)
{
missing
=
true
missing
=
true
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment