Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript content-type

When I add JavaScript files to web pages, I have always done for example like this:

<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript">
    // Custom script
</script>

But today I discovered in the response headers that JavaScript are actually served as application/javascript. Why is that? Is both correct? Or should I change one to the other? What's going on here?

like image 691
Svish Avatar asked Sep 13 '10 11:09

Svish


People also ask

What is Content-Type?

Definition of a Content Type. In technical terms, a Content Type is a reusable collection of metadata for a category of content, with its corresponding taxonomies that allows you to manage information in a centralized, reusable way.

What is Content-Type example?

The Content-Type header is used to indicate the media type of the resource. The media type is a string sent along with the file indicating the format of the file. For example, for image file its media type will be like image/png or image/jpg, etc. In response, it tells about the type of returned content, to the client.

What is HTTP Content-Type?

The Content-Type representation header is used to indicate the original media type of the resource (prior to any content encoding applied for sending). In responses, a Content-Type header provides the client with the actual content type of the returned content.

What is Content-Type text?

The text content type is used for message content that is primarily in human-readable text character format. The more complex text content types are defined and identified so that an appropriate tool can be used to display more complex body parts.


1 Answers

with HTML5, you can just omit the type attribute completely. All browsers assume a default type of JavaScript.

like image 133
bluesmoon Avatar answered Sep 22 '22 17:09

bluesmoon