Re: outputting javascript from a php script?
| From: | Christoph Becker | Date: | Wed, 10 Dec 2014 15:13:20 +0000 |
| Subject: | Re: outputting javascript from a php script? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-324111@lists.php.net to get a copy of this message | ||
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