JavaScript Error: Unexpected Token or Syntax Error After Editing
A missing bracket, quote or comma breaks the whole script file.
Reference guide. This guide is written from established practice and the official documentation of the tools involved. We have not yet tested every step on a live demo site. Back up your site before you change anything.
Fix
- The console shows the file and line. See reading the browser console.
- Look just before that line for a missing
),}, quote or comma. - Use an editor with syntax highlighting and bracket matching.
- If the file was minified or combined by a plugin, disable that setting to see the original error.
- Unexpected token < usually means the script URL returned an HTML page (a 404 or error) instead of JavaScript.
- For JSON problems, validate the text in a JSON checker.
Restore the previous version from backup if you cannot find the cause quickly.
Related guides
- WPForms or Gravity Forms Entries Not Saving
- WordPress Shows the Wrong Time or Publishes at the Wrong Time
- Where to Add Custom CSS or Code in WordPress Without Losing It After Updates
- "The Uploaded File Exceeds the upload_max_filesize" in WordPress: Fix
Did this solve it? If not, email hello@sitefixlab.org with the exact error text and we will look into it. Try the problem finder.