How to check for Javascript Errors

Knowledgebase Docs » General
USEFUL? 5

If your site is producing javascript errors, they will be displayed in your browser’s Javascript console. To check for javascript errors, simply open the console and look for the errors. It’ll look something like this:

Errors are generally marked in red or with a × . Any errors on your site have the potential to halt all other javascript execution, preventing other scripts from being able to run.

The red text described the error (in the example above, the script is calling a function, examplefunc(), which does not exist).

The link on the right shows the script and line number at which the error occurred. Note that this does not necessarily mean that is the problematic code. For example, that line will often show that the error occurs in jquery.js, but bugs in the jQuery core are exceptionally rare and very unlikely to be the source of your issue. Click the arrow on the left to open the Stack Trace, which will show all the functions called along the way, with their scripts and line numbers. Generally scripts coming from themes or plugins are causing the issue.

Here’s how to open the console in various browsers:

Chrome

To open the console in Chrome, you can either:

  1. Use the keyboard shortcut Command – Option – J (Mac) or Control -Shift -J (Windows/Linux).
  2. Select View > Developer > JavaScript Console.

Chrome: Using the Console

Firefox

To open the console in Firefox, either:

  1. Select “Web Console” from the Web Developer submenu in the Firefox Menu (or Tools menu if you display the menu bar or are on Mac OS X)
  2. By pressing its Control-Shift-K (Command-Option-K on the Mac) keyboard shortcut.

Firefox: Web Console

Safari

In Safari, you need to first enable the Web Inspector. Please follow these instructions.