Uncategorized

Javascript console syntax error on Doctype

I just solved an interesting problem.

There was a Doctype syntax error in the console.

This was caused by an invalid javascript file included on the page – invalid meaning there is no file in the src tag, or the file does not end in .js.

The fix was to remove the CMS code that was inserting an empty javascript tag with no src file.

Tricky to track down, simple to fix.

31 thoughts on “Javascript console syntax error on Doctype

  1. I appreciate that. I was fighting with this issue for a long time. I read what you said and started looking at the possibility that the file was loading incorrectly and realized I had named the JS file wrong. That was a waste of 3 days. Thanks, your post helped me figure that out. Thanks again.

    Like

  2. i've found that it's also caused by an empty js file in firefox too.

    so if the file exists, but it has nothing in it, it will in some cases trigger this error.

    Like

  3. Wow, check this. I had accidentally typed a “0” in my google analytics code and changed the domain. Since it was an invalid domain, comcast (my isp) was feeding back a 404 page from their dns server which was causing this syntax error. So, it may not even be your code doing it! Thanks for the heads up!

    Like

  4. Thank you, that's saved me a lot of stress.

    This happened for me when I transferred my work from my local machine to a remote server – a syntax error in the DOCTYPE of all things, and none of my javascript working. It's obvious now that I forgot to check in the javascript file to source control, but in my sleep-deprived state I could have spent hours investigating server configurations and finding out if some doctypes only work on localhost.

    Like

  5. Thanks! For me the error came from having ajax (jQuery) autocomplete calls to a non-existent ajax source. Your post helped me focus on the javascript instead of spacing or syntax in an html file … lots of time saved! Thanks again.

    Like

  6. Thanks Dude. There was problem with ajax request and it tells in Java Script console syntax error in line 123 Doctype. It was because of ajax response was wrong means ajax response of requested page contain js but due to html (header and tag) it was unble to execute js.
    Now I have resolved my problem.

    After all problem was due to JS function.

    Like

  7. Another thing that can cause the same error. Is a javascript file (.js) that is empty, nothing in it, no lines, etc..

    why you might have a blank file could be for so much as a place holder for something your working on or intent on working up soon. Or for whatever reason, anyway. Quick fix for that is simply just putting a comment into the file if anything else

    Like

  8. Awesome Catch! i am used to a Windows environment and recently started working on an Ubuntu server…capitalization counts!

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s