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.

Published Friday, April 11, 2008 9:30 AM by Jason N. Gaylord

Comments

# re: How To: Properly Reference A JavaScript File

Friday, April 11, 2008 12:44 PM by Dave

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?

# re: How To: Properly Reference A JavaScript File

Friday, April 11, 2008 5:07 PM by rja

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

# re: How To: Properly Reference A JavaScript File

Monday, April 14, 2008 3:05 AM by SergeyS

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

# re: How To: Properly Reference A JavaScript File

Wednesday, April 16, 2008 1:08 PM by Jason

Your right Rach. I was drinking decaf. It's all mental. :)

Leave a Comment

(required) 
(required) 
(optional)
(required)