Skip to content

When using <Script> with crossorigin specified, crossorigin is missing from <link> that preloads the script #65879

@mwskwong

Description

@mwskwong

Link to the code that reproduces this issue

https://github.com/mwskwong/missing-cross-origin-from-preload-script

To Reproduce

  1. Build the project
  2. In index.html, observe the <link> that preloads the ad sense script https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js. Note that crossorigin="anonymous" is missing from <link> despite it is specified in <Script>

Current vs. Expected behavior

Current

When including a script with crossOrigin set:

<Script
  async
  crossOrigin="anonymous"
  src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"
/>

crossorigin is missing from the <link> that preloads the script.

Expected

For <link>, crossorigin should be set to the same value as that in <Script>.

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Home
  Available memory (MB): 32493
  Available CPU cores: 20
Binaries:
  Node: 20.12.2
  npm: N/A
  Yarn: N/A
  pnpm: 8.14.1
Relevant Packages:
  next: 14.3.0-canary.68 // Latest available version is detected (14.3.0-canary.68).
  eslint-config-next: 14.3.0-canary.68
  react: 19.0.0-beta-04b058868c-20240508
  react-dom: 19.0.0-beta-04b058868c-20240508
  typescript: 5.4.5
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Script (next/script)

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local), Vercel (Deployed)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Script (next/script)Related to Next.js Script Optimization.bugIssue was opened via the bug report template.locked

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions