Re: outputting javascript from a php script?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Maciek Sokolewicz wrote:

> That's actually quite a difficult question.
> What you're basically asking is what is the mime-type of a javascript file.
> 
> The answer is that it is officially 'application/javascript'.
> However, this has only recently been published as part of the standards.

I am aware of RFC 4329[1], but that is only "Informational", and it
dates back to April 2006.  Is there any other standards document
specifying "application/javascript"?

> Until just a few years ago, there was no agreed mime-type for javascript
> files; this is why you'll see text/javascript, application/x-javascript,
> etc. being used all over the place.
> The HTML4, html5 and xhtml (1 and 1.1) speccs all expect a
> text/javascript mimetype when using javascript.
> 
> In the end... it doesn't really matter that much. You could technically
> send a mime-type of text/plain and it would still work just fine. This
> is simply because most browsers don't trust the headers sent but tend to
> take a peek into the first packets sent, and decide what it contains
> based on that.
> 
> So... I'd personally use application/javascript since that's the
> official mime-type. But it doesn't really matter that much which one you
> use ;)

Unless you have to support old IE.  AFAIK, IE 8 ignores scripts with an
"application/javascript" MIME type.

[1] <http://www.rfc-editor.org/rfc/rfc4329.txt>

-- 
Christoph M. Becker

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux