application/javascript

All MIME types
Application · Standards tree · RFC 9239 (obsoleted).js

Media type / application

application/javascript

The former media type for JavaScript, kept working by every browser but obsoleted in favour of text/javascript.

Obsolete: Send text/javascript instead. This spelling still works but is no longer the registered type.

Browser behaviour

Executes in the page

Charset

charset required

Compression

Compress in transit

Send it like this

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

Send `; charset=utf-8`. Without it the receiver falls back to its own default — for some text types that default is us-ascii, and any non-ASCII character then renders wrong.

Handling verdict

InlineExecutes in the page

Rendered inline, this type executes script in the origin that served it. Never serve untrusted content under it from an origin that holds sessions — use a separate origin, or force a download with Content-Disposition: attachment.

Charsetcharset required

Send `; charset=utf-8`. Without it the receiver falls back to its own default — for some text types that default is us-ascii, and any non-ASCII character then renders wrong.

CompressionCompress in transit

The payload is text-like or otherwise repetitive, so gzip or Brotli removes real bytes. Enable it at the server or CDN.

NameStandards tree

Registered with IANA through a public review process, so the name is stable and every implementation can rely on it meaning the same thing.

Anatomy of the name

RFC 6838

Top-level type

application

Application

Subtype

javascript

Registered in the standards tree.

Structured syntax

none

No suffix, so the payload format is defined entirely by the subtype itself.

Parameters

charset

Beyond the charset rule above, this type defines no parameters of its own.

Response headers

Content-Type: application/javascript; charset=utf-8
X-Content-Type-Options: nosniff
Content-Disposition: inline
Content-Security-Policy: sandbox; default-src 'none'
Vary: Accept-Encoding

nosniff stops the browser second-guessing the type you declared, which is what makes the rest of this reliable. The sandbox directive is the belt-and-braces option when the content is not fully under your control.

Server configuration

extension mapping

nginx

types {
    application/javascript  js;
}

Apache

AddType application/javascript .js
AddCharset UTF-8 .js

Caddy

@type path *.js
header @type Content-Type "application/javascript; charset=utf-8"

Extensions and other spellings

declared

File extensions

File signature

No fixed signature — this format has no reliable magic number, so identify it by parsing rather than by the first few bytes.

Related media types

8
Familyapplication
Treestandards
Suffix
Inlineactive