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 responses to “Javascript console syntax error on Doctype”

  1. Thanks!!! Saved me a headache, that’s for sure 🙂

    Like

  2. Thanks a lot, you saved my day…

    Like

  3. Thank you very much it saves a lot of my time. 🙂

    Like

  4. have no idea how you would find that, but that's a great tip to fix an annoying problem.

    Like

  5. <3

    In my case it was both. The wrong file extension was a typo and therefor pointing to a non-existant file.

    Like

  6. 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

  7. Saved Me DAYS of frustration. I had to include ALL of the .js files that come with script.aculo.us to avoid this error.

    Like

  8. 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

  9. Thank you. I spent a day trying to recognize where the problem is.

    Like

  10. Thanks. You saved my world.

    Like

  11. Thanks man, this one helped me out

    Like

  12. Thanks. It saved a lot of my time.

    Like

  13. 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

  14. thanks!! error gone now

    Like

  15. 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

  16. Thanks, saved me some time.

    Like

  17. Brilliant, thank you! I found out that I was referencing a .js file with a hyphen instead of an underscore very quickly after reading your post.

    Like

  18. Still helping. Thanks for your info.

    Like

  19. 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

  20. Thanks Very Very Much! That's the exact SOLUTION !

    Like

  21. Thanks dude! 3 years later you're still helping people!

    Like

  22. Phoarrh. Dude! Thanks a million. This saved my evening.

    Like

  23. 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

  24. Hey thanks – helped me out just now on my project

    Like

  25. Thanks!

    Like

  26. thanks

    Like

  27. 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

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

    Like

Leave a comment

Trending