473,396 Members | 2,108 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

JavaScript MIME type?

I'm working on a CGI script that creates a dynamically generated .js
file. What MIME type should I use? Every site I go to says something
different: text/javascript, application/javascript,
application/x-javascript, or application/ecmascript. Which one is it?

Aug 20 '05 #1
9 8549
On 20/08/2005 23:56, Daniel wrote:
I'm working on a CGI script that creates a dynamically generated .js
file. What MIME type should I use?


The Content-Type header isn't usually as important as the type
attribute, however the two should match.

The application/ecmascript and application/javascript MIME types were
only recently introduced, so this means that most (all?) user agents
will not recognise them for the time being. As such, you should continue
to use the (officially obsolete) text/javascript type.

Mike

--
Michael Winter
Prefix subject with [News] before replying by e-mail.
Aug 20 '05 #2
Michael Winter wrote:
The application/ecmascript and application/javascript MIME types were
only recently introduced, so this means that most (all?) user agents
will not recognise them for the time being.
Mozilla and Opera recognise application/javascript. I think IE is the
only major browser that doesn't, but I'm not certain about Mac and Linux
browsers. I don't know about application/ecmascript support.
As such, you should continue to use the (officially obsolete) text/javascript type.


Yes, even though text/javascript is now deprecated, it's the only one
that can be safely used in HTML while IE6 is still around. However,
IIRC, IE obeys the type attribute regardless of what the server sends.
Although, it is generally good practice to use the same MIME type in
both places anyway, you can use:

<script type="text/javascript"></script>

and send this in the HTTP headers:

Content-Type: application/javascript; charset=UTF-8

(don't forget to send the correct character encoding information, it
must match the encoding of the file)

--
Lachlan Hunt
http://lachy.id.au/
http://GetFirefox.com/ Rediscover the Web
http://GetThunderbird.com/ Reclaim your Inbox
Aug 21 '05 #3
On Sun, 21 Aug 2005 01:13:10 GMT, Lachlan Hunt
<sp***********@gmail.com> wrote:
However,
IIRC, IE obeys the type attribute regardless of what the server sends.


Only in the default configuration on XP SP2, although I'm not
completely sure which of many settings actually stops it
unfortunately.

Jim.
Aug 21 '05 #4
Michael Winter said the following on 8/20/2005 7:44 PM:
On 20/08/2005 23:56, Daniel wrote:
I'm working on a CGI script that creates a dynamically generated .js
file. What MIME type should I use?

<snip>
As such, you should continue to use the (officially obsolete) text/javascript type.


IIRC, text/javascript was never a registered mime type to begin with,
was it?

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Aug 21 '05 #5
Randy Webb wrote:
IIRC, text/javascript was never a registered mime type to begin with,
was it?


It's been both recently registered with IANA [1] and officially
deprecated. This draft [2] has been accepted, but not yet published as
an RFC.

[1] http://www.iana.org/assignments/media-types/text/
[2] http://www.ietf.org/internet-drafts/...t-types-03.txt

--
Lachlan Hunt
http://lachy.id.au/
http://GetFirefox.com/ Rediscover the Web
http://GetThunderbird.com/ Reclaim your Inbox
Aug 21 '05 #6
On 21/08/2005 02:13, Lachlan Hunt wrote:
Mozilla and Opera recognise application/javascript.


I assume you mean within the Content-Type header? Use with the type
attribute will result in the user agent ignoring the script.

"Recognise" would seem to be an overstatement. If they recognised the
MIME type, it would be usable within the type attribute. Tolerate would
be more accurate, I think.

[snip]

Mike

--
Michael Winter
Prefix subject with [News] before replying by e-mail.
Aug 21 '05 #7
Michael Winter wrote:
On 21/08/2005 02:13, Lachlan Hunt wrote:
Mozilla and Opera recognise application/javascript.
I assume you mean within the Content-Type header? Use with the type
attribute will result in the user agent ignoring the script.

"Recognise" would seem to be an overstatement. If they recognised the
MIME type, it would be usable within the type attribute. Tolerate would
be more accurate, I think.


Yeah, sorry. I knew they accepted it in the Content-Type header and
Deer Park Alpha 2 accepted it in the type attribute, although it seems
that older versions of Mozilla (including Firefox 1.0.x) don't. I also
incorrectly assumed Opera 8.0 supported it in the type attribute.

--
Lachlan Hunt
http://lachy.id.au/
http://GetFirefox.com/ Rediscover the Web
http://GetThunderbird.com/ Reclaim your Inbox
Aug 21 '05 #8
Maybe the script should recognize the browser and send
"text/javascript" or "application/javascript" depending on which
browser they have?

Aug 21 '05 #9
On 21 Aug 2005 12:38:34 -0700, "Daniel"
<we*******@explodingpickle.org> wrote:
Maybe the script should recognize the browser and send
"text/javascript" or "application/javascript" depending on which
browser they have?


browsers don't advertise their acceptance of javascript mime-types.

Just use text/javascript, it's deprecation is not important until
browsers support others.

Jim.
Aug 21 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Luis | last post by:
I have a few input buttons at the end of an asp page. When I change the mime-type of the asp page to create a Word Document which the user can save, the input buttons are not displayed. Is there a...
1
by: Michael Loughry | last post by:
I'm writing a web application that fetches documents from the server and sends them to the client. I do this using the Response.BinaryWrite method. However, is there any way to detect the MIME...
4
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I prompt a "Save As" dialog for an accepted mime type?...
4
by: Sandman | last post by:
Hi there, So here is the situation I'm in. My PHP script does something like this: 1. Update a DB (only once) 2. Send some post data to another PHP script (only once) 3. Output some stuff...
6
by: Mad Hatter | last post by:
Hi folks I'm a bit confused with an upload script that I've written. I want to be able to check the file type of an upload by checking the mime type but I'm not getting the results that I...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.