application/javascript
Application

Overview

application/javascript is the media type for ECMAScript source code executed by browsers and Node.js. However, the current HTML standard designates text/javascript as the recommended legacy type for serving scripts, so both coexist in practice.

Details

Historically many types competed: text/javascript, application/x-javascript, application/javascript. RFC 4329 registered application/javascript as canonical, but WHATWG reverted to recommending text/javascript for interoperability. Either works — browsers execute the <script> — and `charset=utf-8` ensures Korean strings and identifiers in the source decode correctly.

To load ES modules (`import`/`export`, `.mjs`) via <script type="module">, the server must send a proper JavaScript MIME type (text/javascript or application/javascript). A wrong type (e.g. text/plain) makes the browser refuse execution under strict MIME checking. This error commonly appears when a static file server does not know the .mjs extension.

Syntax

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

File extensions

.js.mjs

Notes

Related types

Related headers