Solved

Javascript *.js mime type

Posted on 1998-09-28
5
618 Views
Last Modified: 2008-02-26
i have just included javascript source in a separate file instead of embedding in the HTML document.:-

<SCRIPT SRC="anexample.js">
</SCRIPT>
_________________________________________
according to a netscape javascript manual i must map the .js suffix to the MIME type "application/x-javascript" otherwise navigator improperly loads the javascript.... ..

But i have NOT done the mapping (I have checked all the diff. mime type and have not found a .js entry on the server) and it still works when i request the above HTML document i.e. the javascript src works!

what gives?
0
Comment
Question by:eriklee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 

Expert Comment

by:javaman17
ID: 1271571
Put this in it too
<SCRIPT LANGUAGE="JavaScript" Src=="anexample.js">
0
 

Author Comment

by:eriklee
ID: 1271572
so Javaman, why does it work?
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1271573
eriklee: The newer browsers makes an effort to figure out the contents from the suffix. If you change the name to .myjs and map that to application/x-javascript it will only work while the mapping is in effect.
Also if the src was pointing to a cgi, the cgi could output the
Content-type: application/x-javascript HTTP header and you would also be fine.

javaman17: You do not answer the question (did you read it?) and you add to the confusion with a typo...

Michel
0
 

Author Comment

by:eriklee
ID: 1271574
hi Michel,
thanks for your insight. Interesting. I tested based on your theory about the newer browser checking out the conttent of the SRC='files'  (i think the older ones will falter).

Using Netscape4.05  after i changed the xyz.js to xyz.jsx and it still works without having to use mappings at all - the mime-type mapping just doesn't play a part at all.

Now would u like to report your reply as an answer
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 50 total points
ID: 1271575
The newer browsers makes an effort to figure out the contents from the suffix.
Older ones (also depending on server) needs the mime mapping at server level.

If you change the name to .myjs and map that to application/x-javascript it should only work while the mapping is in effect. It seems however that Netscape will accept any extention in the src. This has not been verified except by you.

If the src was pointing to a cgi, the cgi could output the Content-type: application/x-javascript HTTP header and you would also be fine.

There appear to be an intermittent bug in NS 4.05 that sometimes shows the source instead of parsing it. A reload fixes it.

Netscape 3 will parse any JS1.2 in a script file, giving errors if the javascript keyword in not recognised. The workaround is putting js1.2 inline.

This is more or less the story on JS src files

Michel
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses
Course of the Month10 days, 15 hours left to enroll

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question