"Script error." in JavaScript — What It Means and How to Fix It

What the JavaScript error "Script error." means and how to fix it.

Published October 30, 2026

'Script error.' is a deliberately vague message browsers show for errors in scripts loaded from another origin, to avoid leaking information.

What it means and why it happens

Add the crossorigin attribute and send CORS headers from the script's server to see real details.

Read the full message: it names the file and line where the problem was detected, which is the best place to start.

What you see

run the code
Script error. at :0:0

Practical examples

Code that triggers it

<script src="https://cdn.example.com/app.js"></script>

The fix

<script src="https://cdn.example.com/app.js" crossorigin="anonymous"></script>
<!-- server: Access-Control-Allow-Origin: * -->

window.onerror

window.onerror = (msg, src, line, col, err) => report({ msg, src, line, col, stack: err?.stack })

Common mistakes

  • Missing crossorigin attribute.
  • CDN without CORS headers.
  • Ignoring the error because it looks empty.

Key takeaways

  • Script error.: 'Script error.' is a deliberately vague message browsers show for errors in scripts loaded from another origin, to avoid leaking information.
  • Read the message and the line number first.
  • Fix the cause, don't just silence the error.

FAQ

Can I read the real message?

Only after enabling CORS for the script.

How do I find which line caused Script error.?

The error message and stack trace show the file and line; start there and work backwards.

More JavaScript articles