Javascript *.js mime type

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?
erikleeAsked:
Who is Participating?
 
Michel PlungjanConnect With a Mentor IT ExpertCommented:
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
 
javaman17Commented:
Put this in it too
<SCRIPT LANGUAGE="JavaScript" Src=="anexample.js">
0
 
erikleeAuthor Commented:
so Javaman, why does it work?
0
 
Michel PlungjanIT ExpertCommented:
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
 
erikleeAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.