TapCub is live — analytics, insights and live chat, free on one platform
Analytics

Script Error: Why Browsers Hide the Message and How to See It

"Script error." is the browser masking an error from a cross-origin script, not a bug type. What the HTML Standard hides, the two-step CORS fix in a safe order, which scripts you can and cannot fix, and a worked week of errors.

Xu An Published Nov 28, 2026 13 min read Analytics
Sample data: after the CORS fix, 410 of 520 masked errors arrive with a file and line, split into three bugs; 110 stay masked because they come from third-party tags. The week total stays 760 errors (1.58% of 48,000 pageviews).Sample data

"Script error." is not a bug type. It is what the browser reports when a script loaded from another origin throws an error and was not fetched with CORS: the HTML Standard replaces the message, blanks the file and sets line and column to 0. You can unmute your own scripts with a crossorigin attribute plus an Access-Control-Allow-Origin header. Third-party tags you do not control should be grouped, checked for impact and ignored or escalated.

What you will learn

  • "Script error." is the browser muting a cross-origin script error: null error, empty file, line 0, column 0
  • Fix your own scripts by sending Access-Control-Allow-Origin first, then adding crossorigin="anonymous"; the reverse order stops the script loading
  • Third-party tags without CORS headers cannot be unmuted: judge them by user impact, then ignore or escalate

What does "Script error." mean?

"Script error." is not a kind of bug. It is the placeholder message a browser hands to your error handler when the error was thrown by a script loaded from a different origin, and that script was not fetched with CORS. The real message, file, line and stack still exist inside the browser; your page is simply not allowed to see them.

The rule is written into the HTML Standard. When a classic script is fetched, the browser sets a "muted errors" flag to true if the response was CORS-cross-origin. When an error from a script with that flag is reported, the standard replaces the details: the error object becomes null, the message becomes "Script error.", the filename becomes an empty string, and the line and column both become 0. That is exactly what monitoring tools record, which is why one opaque group can swallow dozens of unrelated bugs.

"Different origin" is stricter than "different website". An origin is scheme + host + port. A bundle served from https://cdn.example.com to a page on https://www.example.com is cross-origin. So is http:// versus https://, or the same host on port 8080. Many teams first meet "Script error." right after moving their own JavaScript to a CDN subdomain.

For the wider picture of front-end errors and how to triage them, see JavaScript error. This article covers the one cause that produces this exact message, and what to do about it.

Why do browsers hide the details?

The HTML Standard describes the muted errors flag as existing so that error details from cross-origin scripts are not exposed, because they could leak private information. A concrete way to picture it: a page you visit could load a script URL from a site where you are logged in. If the browser reported the full error text from that response, the page could learn things about your account on the other site. Muting closes that hole by default.

The same policy has a way out. If the script's server explicitly opts in with CORS headers, and your page asks for the script in CORS mode, the response is no longer CORS-cross-origin and the flag is not set. You get the full error back. The decision belongs to whoever controls the script's server, which is why the fix works for your own files and not for someone else's.

What changes once CORS is set: before and after

Sample data: one cross-origin bundle, https://cdn.example.com/checkout.js, throws a TypeError when a promo code field is missing. Here is what a global error handler (window.onerror or an error event listener) receives in each case.

ArgumentWithout CORS (muted)With crossorigin="anonymous" + Access-Control-Allow-Origin
messageScript error.TypeError: Cannot read properties of null (reading 'value')
source (filename)empty stringhttps://cdn.example.com/checkout.js
line0214
column031
error objectnullTypeError with a full stack trace

The muted row is fixed by the standard, so it is the same in every browser that follows it. The unmuted row depends on your code; the values above are illustrative. The important point is the shape: after the fix, each distinct bug arrives with its own message and location, so your monitoring can split one useless group into several fixable ones.

How to fix "Script error." in two steps

Both steps are required. Either one on its own does nothing useful, and the first one on its own can break the page.

Step 1: request the script in CORS mode. Add the crossorigin attribute to the script tag:

<script src="https://cdn.example.com/checkout.js" crossorigin="anonymous"></script>

MDN documents three values. anonymous (also bare crossorigin or an empty value) makes a CORS request that sends cookies only to the same origin. use-credentials makes a CORS request that always sends cookies. Without the attribute, a classic script is fetched without CORS and its errors reach window.onerror with limited detail. Module scripts (type="module") are always fetched in CORS mode, so for them only use-credentials changes anything.

Step 2: have the script's server allow your origin. The response for checkout.js must include an Access-Control-Allow-Origin header that matches your page:

Access-Control-Allow-Origin: https://www.example.com
Vary: Origin

For a public static file fetched without credentials, Access-Control-Allow-Origin: * also works. MDN is explicit that the wildcard cannot be combined with credentials: a request using use-credentials with a * response fails. When the server answers with a specific origin rather than *, MDN says it should also send Vary: Origin, so caches do not hand one site's response to another.

Why the order matters. If you add crossorigin and the server does not send a matching header, the browser treats the CORS check as failed and refuses to run the script at all. Ship the header first, confirm it on the live CDN response, then add the attribute.

If you also use Subresource Integrity. An integrity attribute on a cross-origin script already requires a CORS fetch, so tags with integrity usually carry crossorigin="anonymous" too. Check that the CDN header is in place before adding either.

CheckHow to verifyExpected result
Header on the live responseRequest the script URL with an Origin header and read the response headersAccess-Control-Allow-Origin matches your page origin or is *
Vary when origin is specificSame responseVary includes Origin
No wildcard with credentialsCompare the crossorigin value with the headeruse-credentials only with a specific origin
Attribute on the tagView the page sourcecrossorigin="anonymous" (or use-credentials) on each own script
Script still runsLoad the page with the console openNo CORS error; the feature works
Errors unmutedTrigger a known error or wait a dayNew groups show file name and line instead of Script error.

Run the first three checks before you change any script tag; the fourth to sixth after.

Which scripts need it: a decision rule

Not every "Script error." can or should be fixed. Sort the scripts on your page by who controls the server:

Script sourceCan you set the response header?What to do
Your own bundle on your CDN or a subdomainYesAdd Access-Control-Allow-Origin on the CDN, then crossorigin="anonymous" on the tag
Same host, different scheme or portYesSame as above, or serve it from the page's own origin
Your own script that needs cookies to loadYescrossorigin="use-credentials" plus a specific origin in the header, never *
Third-party tag that already sends CORS headersNo, but they doAdd crossorigin="anonymous" to the tag; check the vendor's response headers first
Third-party tag without CORS headersNoYou cannot unmute it. Group its errors, check whether they affect users, then filter or ignore
Inline script or same-origin fileNot neededAlready unmuted; a "Script error." here means the error came from elsewhere

The last group is larger than most teams expect. The HTTP Archive's 2024 Web Almanac reports that around 92% of pages use third parties, with a median of 66 third parties on the top thousand sites and 27 across the top million. Some of those scripts will throw, and you will never see their details. The right response is a decision, not a fix: does the error stop a user from doing something?

A practical test for a masked third-party group: open a few affected sessions and see whether visitors still completed the page's main action. If they did, mark the group as ignored and move on. If the error lines up with abandoned checkouts or failed forms, raise it with the vendor, because only they can change the header.

Worked example: a week of masked errors

Sample data: a store's site has 48,000 pageviews in one week and records 760 JavaScript errors, an error rate of 760 ÷ 48,000 = 1.58%.

Before the fix, the error list looks like this:

  • Script error.: 520 occurrences (68.4% of all errors)
  • TypeError: Cannot read properties of null: 180
  • ReferenceError: promoBanner is not defined: 60

The team serves its own code from a CDN subdomain. They add Access-Control-Allow-Origin: https://www.example.com and Vary: Origin to the CDN, verify the header on the live response, then add crossorigin="anonymous" to their own three script tags. The following week has the same traffic and the same bugs. The 520 masked errors split up:

  • 260 are a TypeError in checkout.js, line 214, when the promo field is missing
  • 95 are a RangeError in carousel.js on very narrow screens
  • 55 are a SyntaxError from JSON.parse in cart.js when a saved cart is corrupted
  • 110 stay as Script error.: they come from two third-party tags the team cannot change

Three things follow from these numbers:

  1. The error count did not change. 260 + 95 + 55 + 110 = 520, and the weekly total is still 760, so the error rate is still 1.58%. Unmuting changes what you can see, not how many errors happen.
  2. The opaque share fell from 68.4% to 14.5% (110 of 760). The team now has three specific bugs with file and line, and the largest (260 errors in checkout) goes to the top of the list.
  3. The remainder is a decision. If the team ignores the third-party group after checking that affected sessions still convert, the errors they act on fall to 650, a rate of 650 ÷ 48,000 = 1.35%.
app.tapcub.com

Where the 520 masked errors went

sample week, errors
TypeError in checkout.js260
Script error. (third-party tags)110
RangeError in carousel.js95
SyntaxError in cart.js55
Sample data
Sample data: after the CORS fix, 410 of 520 masked errors arrive with a file and line, split into three bugs; 110 stay masked because they come from third-party tags. The week total stays 760 errors (1.58% of 48,000 pageviews).

Common mistakes when fixing "Script error."

  • Adding crossorigin before the header exists. The script stops loading entirely. Deploy the header first.
  • Using * with use-credentials. The CORS check fails. Send the exact origin instead.
  • Forgetting Vary: Origin with a specific origin. A shared cache may serve the header meant for one origin to another, so errors unmute on one site and the script breaks on the next.
  • Testing against a cached file. The header has to be on the response the browser actually gets. Purge the CDN cache or test with a fresh URL.
  • Treating the masked group as one bug. It is many bugs from many scripts with nothing in common except the missing details. Do not assign it as a single ticket.
  • Expecting the fix to lower the error rate. It will not. Count before and after the same way, and measure progress by masked share and by real bugs fixed.

Finding and triaging script errors in TapCub

Here is the worked example inside TapCub, step by step.

TapCub error groups table with error type, occurrences and affected sessions for six groups
Demo data: TapCub groups JavaScript errors and shows occurrences and affected sessions for each group, the list you triage after unmuting your own scripts. The numbers are demo data, not customer data.
  1. Make sure errors are collected. Error collection is switched on in the tracking snippet with data-errors="true", which the default snippet includes; it loads a small extra script. If it is off, Monitoring › Errors shows a notice pointing you to the tracking code. Step-by-step setup is in find JavaScript errors.
  2. Read the size of the problem. Monitoring › Errors shows error count, error rate (error count ÷ pageviews in the selected range), affected visitors and affected sessions, plus a trend line. In the example, that is 760 errors and 1.58%.
  3. Find the masked group. Each group shows its count, the sessions involved and when it was last seen. Because the browser passes only Script error. with no file or line, masked errors from different scripts have nothing to tell them apart, so expect them together under that message. Expand the group to see each occurrence's time, page, place, device and session, and look for pages that load your own CDN bundles.
  4. Decide per group. After the CORS fix, the new groups with real file names are the ones to fix. For the third-party remainder, open a session from an occurrence (the link goes to the session view) and check whether the visitor still finished the page's task. If yes, mark the group Ignored; mark fixed groups Resolved. Both statuses take a group out of Active.
  5. Check user impact. Under the groups, the frustration table lists pages with error clicks: a script error within 1 second after a click. A masked group that shows up as error clicks on a checkout page is worth raising with the vendor, even if you cannot see its stack.

TapCub records and groups the errors your pages report. It cannot unmute a third-party script; only the server that hosts the script can, by sending CORS headers.

FAQ

What is a script error?

In a browser, "Script error." is the generic message reported when a script loaded from another origin throws an error and was not fetched with CORS. The HTML Standard tells browsers to replace the real message with "Script error.", the file with an empty string and the line and column with 0, so that cross-origin scripts cannot leak information to the page.

How do I fix "Script error."?

For scripts you control, do two things: make the script's server send Access-Control-Allow-Origin with your page's origin (or * if no credentials are involved), then add crossorigin="anonymous" to the script tag. Add the header first, because the attribute without the header stops the script from loading.

Can I fix "Script error." from third-party scripts?

Only if the third party already sends CORS headers, in which case adding crossorigin="anonymous" to their tag unmutes the errors. If they do not, you cannot see the details. Check whether the errors affect what users do, ignore the group if they do not, and raise it with the vendor if they do.

Is "Script error." harmful to users?

Not necessarily. The message only says details were hidden; the underlying error may break a button or may be harmless noise from a tag. Judge it by impact: look at sessions where it happened, check error clicks and see whether visitors still completed the page's goal.

Why does "Script error." show line 0?

Because the browser deliberately sets the line and column to 0 for muted errors, along with an empty filename and a null error object. Nothing in your code is on line 0; the location simply was not shared with your page.

Sources

Filed underAnalytics

Was this article helpful?

We use your answers to fix and expand this page.

Xu An

Customer Experience Consultant

Writes about live chat, visitor conversations, and self-service, sharing practical ways to make customer communication clearer and more effective.

See which errors your visitors actually hit

Error count, error rate, affected sessions and grouped errors you can mark resolved or ignored, next to real-user page performance.

See your data clearly. Find your growth.

Every click, backed by data. Install one line of code and see your first numbers in a minute.

No credit card · Free plans for analytics and chat · Cookieless analytics