Reply to Re: text/javascript

Your name:

Reply:


Posted by Richard Cornford on 06/30/05 17:52

Michael Winter wrote:
> On 30/06/2005 08:44, John Dunlop wrote:
<snip>
>> Then you can send your javascript files with the MIME
>> type <application/javascript> and have them executed
>> by at least some browsers.
>
> Care to name any? :)
>
> I could be wrong of course, and I would have no problem
> with that, but as I see it these registrations are less
> than useless for the time being.

There are two very distinct aspects to this. The HTTP headers that
accompany an external JS file, and the TYPE attribute as required by
HTML in a SCRIPT element's opening tag.

Some time ago, in response to having the absence of any official MIME
type for javascript pointed out to me, I did some experiments sending JS
files to browsers with MIME types that varied from the totally
fictitious, through the utterly inappropriate, to the wrong but not too
unexpected (text/html, text/plain and the like). And I could not find a
browser that would not happily swallow and execute the script file
regardless of the MIME type asserted.

Granted I did not use any browsers as old as Netscape 3 for those test,
and I understand that Netscape 3 did have an attitude towards the MIME
type of external JS files (preferring application/x-javascript).

However, in the absence of any official MIME type for javascript it is
not surprising that browsers should appear to have a habit of disregard
that header entirely and just treating whatever is sent as potential JS
source code (which is also why 404 error pages asserting that they are
text/html still get interpreted as JS and result in apparent syntax
errors). There is little else they could reasonably do.

As a result sending application/javascript as an HTTP header would be as
insignificant as sending anything else, and so harmless (and, if
officially adopted as the correct MIME type, theoretically the right
thing to do).

The HTML TYPE attribute of SCRIPT elements was obviously necessary if
the W3C didn't want to tie web browsers to a single script type, but it
was a mistake for the HTML spec to reference an official list of MIME
types and then cite an exempt text/javascript MIME type that did not
appear in that list. The effect was to leave text/javascript as the only
possible TYPE value for use in HTML with javascript, but without any
real reason for its use except that it had been provided as an example
along side the words "Authors must supply a value for this attribute".

The practical upshot is that if a SCRIPT element is to have a TYPE
attribute, and be expected to treat its contents or referenced file as
javascript, it is going to need to be TYPE="text/javascript" to work
cross browsers (at least for the next 3 or 4 years). But then I suppose
that if TYPE is intended to express a MIME type then an HTTP header that
is also supposed to be a MIME type should probably assert the same (even
if fictional) type.

It's a mess that should have been sorted out years ago, but may now
never be satisfactorily resolved.

Richard.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация