Errors / JavaScript errors
Uncaught TypeError: x is not a function
A script tried to use something as an action that is not one, and stopped.
The feature that calls it does nothing when used: a slider that never moves, a list that never renders.
Why it happens
- Two versions of a library on one page, or a plugin loaded before the library it extends:
$(…).slick is not a functionis a jQuery plugin missing from the jQuery that ran. - A typo or a renamed method after an upgrade.
- Calling an array method on something that is not an array:
data.map is not a functionwhen the API answered an object or an error. - A variable reused: a function name overwritten by a value somewhere else.
How to fix it
- Log the thing before the dot and check what it really is (
console.log(typeof data, data)). - For plugins, load the library once, then its plugins, in that order; look for a second copy of jQuery added by a theme or a plugin.
- For API data, check the response shape before calling array methods on it.
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.
Often seen with
- $ / jQuery is not definedA script needs jQuery and ran before jQuery was on the page, or jQuery never loaded.
- x is not a constructorA script tried to create something from a library that was not loaded the way it expected.