App router configuration incorrectly sets async tags instead of defer #66958
Labels
bug
Issue was opened via the bug report template.
Performance
Anything with regards to Next.js performance.
Script (next/script)
Related to Next.js Script Optimization.
Link to the code that reproduces this issue
https://codesandbox.io/p/devbox/angry-chaum-lrfdsw
To Reproduce
On sandbox
<script>
tags<script>
tagsOn a repository
npm run build
npm start
view:sourcehttp://localhost:3000
async=""
Current vs. Expected behavior
I believe this is a regression from the
pages
router which is not documented anywhere.<script>
tags should have thedefer
tag on them<script>
tags have theasync
tag on themWe've noticed a degradation in our time to render because now the
async
tag is being used which can block the main thread if its found by the browser first (see more: https://www.catchpoint.com/blog/new-render-blocking-indicator-in-chrome-and-webpagetest).I don't think script tags in this case should be async and should be
defer
like before given that the browser will try and parse the javascript as its still rendering the page.Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 23.4.0: Wed Feb 21 21:44:43 PST 2024; root:xnu-10063.101.15~2/RELEASE_ARM64_T6000 Available memory (MB): 65536 Available CPU cores: 10 Binaries: Node: 18.19.0 npm: 10.2.3 Yarn: 1.22.19 pnpm: N/A Relevant Packages: next: 14.2.4 // Latest available version is detected (14.2.4). eslint-config-next: 14.2.4 react: 18.3.1 react-dom: 18.3.1 typescript: 5.4.5 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Performance, Script (next/script)
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local), next start (local), Vercel (Deployed), Other (Deployed)
Additional context
No response
The text was updated successfully, but these errors were encountered: