How To: Properly Reference A JavaScript File

Wow. After 2 hours of pain and suffering, I ran into my own daily WTF. I had some script contained within a .js file in my web. Like many times before, I created a reference to the script in the header. However, the script would only work in the Internet Explorer family and not in Firefox. After some aggrevation (and my Starbuck's Pike Place Roast kicking in) I realized that the MIME type was set to text/jscript instead of text/javascript. I wish we can modify IntelliSense locally to get items added/removed as needed.

3 Comments

  • Just out of curiosity - how do you handle referencing a function in a .js file, when the js file hasn't fully loaded yet -we've all seen that happen. Do you trap the error and inform the user that the file hasn't fully loaded yet or do you just let them click on things and let the little error icon show in the lower left of the browser?

  • Jason, you're not supposed to be drinking caffeine!

  • Freezing a web page with "wait, scripts are loaded" message until all scripts is loaded.

Comments have been disabled for this content.