Skip to content

Errors / JavaScript errors

Uncaught ReferenceError: x is not defined

A script used a name nobody declared, usually because another script it depends on did not load first.

The script stops at that line; whatever it was about to set up does not happen.

Why it happens

  • The script that defines it failed to load (a 404, a blocked domain) or loads after the one that uses it: async scripts run in whatever order they arrive.
  • A typo, or a variable used outside the function where it was declared.
  • Code written for Node (require, process, module) running in the browser.

How to fix it

  1. Find where the name should come from and check that file loaded, in the network tab or in a Broken Here report's failed requests.
  2. Load dependencies in order: no async on a script another one needs, or defer on both.
  3. Wrap optional third-party calls: if (typeof gtag === "function") gtag(…).

Whose problem it is

Either the site's own code or a third party's, depending on where it comes from.

Does your site have it?

Free, no account. We open your page and four more in a clean Chrome and list every error like this one, with the page and the click that caused it. How the free page check works.

Check only sites you run or have permission to check.

Often seen with