473,773 Members | 2,334 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 8570
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.javas cript 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 "applicatio n/javascript" depending on which
browser they have?

Aug 21 '05 #9
On 21 Aug 2005 12:38:34 -0700, "Daniel"
<we*******@expl odingpickle.org > wrote:
Maybe the script should recognize the browser and send
"text/javascript" or "applicatio n/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
2926
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 way to display the buttons AND have the mime type set to vnd.ms-word on the same page? <% @ Language=VBScript %> <% Response.ContentType = "Application/vnd.ms-word" Response.AddHeader "content-disposition",
1
3047
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 type of a given file? Or a catch-all MIME type I could use? These files will likely mainly be word and pdf documents, but they can conceivably be anything.
4
434
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I prompt a "Save As" dialog for an accepted mime type? ----------------------------------------------------------------------- It is not possible with client-side JavaScript. Some browsers accept the Content-Disposition header, but this must be added by the server. Taking the form:- « Content-Disposition: attachment; filename=filename.ext » ...
4
1955
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 related to 1 and 2. I've done #2 by using input type="hidden" on a form, like so: print "<form action='../dir/register.php' method='post'
6
6258
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 thought I should. According to what I've read .zip files should return something like 'application/zip' or 'application/x-zip-compressed', RAR should return 'application/x-rar-compressed' but both return 'application/octet-stream'. I'm getting the...
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10264
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9914
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8937
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7463
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4012
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3610
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.