TextText-based
text/javascript
JavaScript (Text)
Reference for text/javascript, the official MIME type for JavaScript as standardized in RFC 9239 for use in HTML pages.
MIME Type Detector
Drop a file to detect its MIME type — no upload, runs in your browser
📄
Drop any file here or click to choose
Expected extensions: .js, .mjs
HTTP Content-Type Header
HTTP Header
Content-Type: text/javascript; charset=utf-8Associated File Extensions
.js.mjs
Quick Facts
| MIME Type | text/javascript |
| Category | Text |
| Type | Text-based (human-readable) |
| Extensions | .js, .mjs |
Common Usage
text/javascript is the IANA-recommended MIME type for JavaScript (RFC 9239), replacing the older application/javascript. HTML script tags use this type by default.
Web servers, CDNs, and build tools should serve JavaScript files with this MIME type for optimal browser compatibility.
Code Examples
HTML
<!-- Link or embed with explicit type -->
<link rel="stylesheet" href="file.js" type="text/javascript">
<!-- Or for script/media elements -->
<script type="text/javascript" src="file.js"></script>Node.js
// Express.js
app.get('/file', (req, res) => {
res.type('text/javascript');
res.send(data);
});
// Node.js http
res.writeHead(200, { 'Content-Type': 'text/javascript' });nginx
# nginx.conf — add to types block or use default
types {
text/javascript js mjs;
}
# Or set for a specific location
location /api/ {
default_type text/javascript;
}Related MIME Types
More Text MIME Types
Other text types in the Text family
Related Tools
Explore More MIME Types
Browse our complete reference of 185 MIME types with usage examples, HTTP headers, and code snippets.