Friday, January 11, 2013

JavaScript file in HTML head wont run

Problem:
Recently while developing I ran into an issue where I was dynamically adding JavaScript files to my page using PHP. The problem was that none of those JavaScript files would execute their code.

Solution: 
After looking for any errors in developer tools and not getting any, I was stumped. I first tested by adding console logging code to the JavaScript files to ensure they never got run. Once I had done this I went about removing the statements from the page to see if placing things back line by line would improve the situation. Finally, I noticed that the type value was incorrectly set in the script tag. Once this was changed from "text/javscript" to "text/javascript" my JavaScript files began to run correctly.

No comments: