Skip to content
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

feat: Add async to body scripts (update: Use defer instead) #5704

Merged
merged 5 commits into from
May 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/server/template-renderer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export default class TemplateRenderer {
const async = this.getUsedAsyncFiles(context)
const needed = [initial[0]].concat(async || [], initial.slice(1))
return needed.filter(isJS).map(file => {
return `<script src="${this.publicPath}/${file}"></script>`
return `<script src="${this.publicPath}/${file}" defer></script>`
}).join('')
} else {
return ''
Expand Down
6 changes: 3 additions & 3 deletions test/ssr/ssr-template.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,10 @@ describe('SSR: template option', () => {
// state should be inlined before scripts
`<script>window.${options.stateKey || '__INITIAL_STATE__'}={"a":1}</script>` +
// manifest chunk should be first
`<script src="/manifest.js"></script>` +
`<script src="/manifest.js" defer></script>` +
// async chunks should be before main chunk
`<script src="/0.js"></script>` +
`<script src="/main.js"></script>` +
`<script src="/0.js" defer></script>` +
`<script src="/main.js" defer></script>` +
`</body></html>`

createClientManifestAssertions(true)
Expand Down