JavaScript MIME type: text/javascript

text/javascript

The MIME type for JavaScript, in both .js and .mjs files, is text/javascript. RFC 9239 (2022) made it the only current name and marked the rest obsolete: application/javascript, application/x-javascript, application/ecmascript, text/ecmascript, text/jscript, text/livescript and the versioned text/javascript1.0 to 1.5. It reverses RFC 4329, which in 2006 had steered everyone toward application/javascript; the industry kept using text/javascript, and HTML defaults to it. RFC 9239 also added .mjs as the extension for code parsed as a module. Search any of the retired names in the tool below and it resolves to text/javascript, whose card lists all 14.

text/javascript   JavaScript (ECMAScript)
.js .mjs
Content-Type: text/javascript; charset=utf-8

charset

The only parameter is charset, and it only applies to classic scripts. RFC 9239 requires module sources to be UTF-8 and decodes them as UTF-8 whatever the header says. For a classic script, a byte order mark beats the header, and the header beats the default.

What browsers check

  • Module scripts are strict. A <script type="module">, a static or dynamic import, and a module worker run only if the response has a JavaScript MIME type. The obsolete names still pass: the MIME Sniffing standard lists 16 JavaScript MIME types, application/javascript and application/x-javascript among them. What fails is text/plain, text/html, application/octet-stream or no type at all.
  • The usual text/html is a single-page app’s fallback. A request for a chunk that no longer exists, such as /assets/index-3f2a.js after a deploy, gets index.html with a 200, and the browser refuses it with a strict MIME type error.
  • Classic scripts. A plain <script src> runs under most wrong types, but never under image/*, audio/*, video/* or text/csv. With X-Content-Type-Options: nosniff, it needs a JavaScript MIME type too.

Servers that still say application/javascript

nginx’s stock mime.types maps js to application/javascript and has no mjs line, so a .mjs file falls through to default_type, which the shipped nginx.conf sets to application/octet-stream, and the module doesn’t load. Express 4’s express.static serves both extensions as application/javascript; charset=UTF-8; Express 5 sends text/javascript; charset=utf-8. Python’s built-in mimetypes table switched to text/javascript in 3.12. Only the missing mjs breaks anything.

In your stack

# In the http block, after include mime.types. The later line wins,
# with a "duplicate extension" warning for js.
types {
    text/javascript  js mjs;
}

Apache’s bundled mime.types already maps both to text/javascript; on an older one:

AddType text/javascript .js .mjs
// Express 4: correct what express.static picks
app.use(express.static('dist', {
  setHeaders(res, path) {
    if (/\.m?js$/.test(path)) res.setHeader('Content-Type', 'text/javascript; charset=utf-8');
  },
}));
aws s3 sync dist s3://my-bucket --exclude '*' --include '*.js' --include '*.mjs' \
  --content-type 'text/javascript; charset=utf-8'
import mimetypes
mimetypes.add_type("text/javascript", ".js")    # Python 3.11 and older
mimetypes.add_type("text/javascript", ".mjs")

Try it in the MIME Type Lookup

text/javascript JavaScript (ECMAScript)

  1. text/javascriptJavaScript (ECMAScript)

    .js.mjs

    Older names: application/javascript, application/x-javascript, text/javascript1.0, text/javascript1.1, text/javascript1.2, text/javascript1.3, text/javascript1.4, text/javascript1.5, text/jscript, text/livescript, text/ecmascript, application/ecmascript, application/x-ecmascript, text/x-ecmascript

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

Every type, 311 of them

TypeExtensionsDescription
application/atom+xml.atomAtom feed
application/cbor.cborConcise Binary Object Representation
application/dash+xml.mpdMPEG-DASH manifest
application/dicom.dcmDICOM medical image
application/epub+zip.epubEPUB e-book
application/fdf.fdfAdobe Acrobat form data
application/geo+json.geojsonGeoJSON geospatial data
application/geopackage+sqlite3.gpkgOGC GeoPackage
application/gml+xml.gmlGeography Markup Language
application/gpx+xml.gpxGPS Exchange Format · unofficial
application/graphql.graphql .gqlGraphQL document · unofficial
application/gzip.gz .tgzGzip compressed data
application/illustrator.aiAdobe Illustrator artwork · unofficial
application/java-archive.jarJava archive
application/java-vm.classJava class file · unofficial
application/json.jsonJSON data
application/kml+xml.kmlKeyhole Markup Language · unofficial
application/ld+json.jsonldJSON-LD linked data
application/manifest+json.webmanifestWeb app manifest
application/mathematica.nb .ma .mbMathematica notebook
application/msword.doc .dotMicrosoft Word document
application/mxf.mxfMaterial Exchange Format
application/octet-stream.binArbitrary binary data
application/oebps-package+xml.opfEPUB package descriptor
application/ogg.ogxOgg container
application/onenote.one .onepkgMicrosoft OneNote · unofficial
application/pdf.pdfPortable Document Format
application/pgp-signature.asc .sigOpenPGP signature
application/pkcs7-mime.p7m .p7cCMS envelope or certificate
application/pkcs7-signature.p7sCMS detached signature
application/pkix-cert.cerPKIX certificate
application/pkix-crl.crlCertificate revocation list
application/postscript.eps .psPostScript program
application/rdf+xml.rdfResource Description Framework
application/rss+xml.rssRSS feed · unofficial
application/rtf.rtfRich Text Format
application/smil+xml.smil .smiSynchronized Multimedia Integration Language
application/sql.sqlSQL script
application/toml.tomlTOML configuration
application/ttml+xml.ttml .dfxpTimed Text Markup Language subtitles
application/unityweb.unitywebUnity web player data · unofficial
application/vnd.adobe.air-application-installer-package+zip.airAdobe AIR application · unofficial
application/vnd.amazon.ebook.azwAmazon Kindle e-book · unofficial
application/vnd.android.package-archive.apkAndroid app package · unofficial
application/vnd.apache.arrow.file.arrowApache Arrow IPC file
application/vnd.apple.installer+xml.pkg .mpkgApple installer package
application/vnd.apple.keynote.keyApple Keynote presentation
application/vnd.apple.mpegurl.m3u8HTTP Live Streaming playlist
application/vnd.apple.numbers.numbersApple Numbers spreadsheet
application/vnd.apple.pages.pagesApple Pages document
application/vnd.coffeescript.coffeeCoffeeScript source
application/vnd.comicbook+zip.cbzComic book archive, ZIP
application/vnd.comicbook-rar.cbrComic book archive, RAR
application/vnd.corel-draw.cdrCorelDRAW drawing · unofficial
application/vnd.cups-ppd.ppdPostScript printer description
application/vnd.debian.binary-package.debDebian package
application/vnd.framemaker.fmAdobe FrameMaker document
application/vnd.garmin.tcx+xml.tcxGarmin Training Center XML · unofficial
application/vnd.google-earth.kml+xml.kmlKeyhole Markup Language, Google variant
application/vnd.google-earth.kmz.kmzKeyhole Markup Language, zipped
application/vnd.iccprofile.icc .icmICC color profile
application/vnd.lotus-wordpro.lwpLotus Word Pro document
application/vnd.maxmind.maxmind-db.mmdbMaxMind GeoIP database
application/vnd.ms-cab-compressed.cabMicrosoft cabinet archive
application/vnd.ms-excel.xls .xla .xltMicrosoft Excel spreadsheet, legacy
application/vnd.ms-excel.sheet.binary.macroenabled.12.xlsbMicrosoft Excel binary workbook
application/vnd.ms-excel.sheet.macroenabled.12.xlsmMicrosoft Excel workbook with macros
application/vnd.ms-fontobject.eotEmbedded OpenType font
application/vnd.ms-htmlhelp.chmCompiled HTML Help
application/vnd.ms-officetheme.thmxMicrosoft Office theme
application/vnd.ms-outlook.msgMicrosoft Outlook message · unofficial
application/vnd.ms-powerpoint.ppt .pot .ppsMicrosoft PowerPoint presentation, legacy
application/vnd.ms-powerpoint.presentation.macroenabled.12.pptmMicrosoft PowerPoint presentation with macros
application/vnd.ms-project.mppMicrosoft Project plan
application/vnd.ms-visio.drawing+xml.vsdxMicrosoft Visio drawing · unofficial
application/vnd.ms-word.document.macroenabled.12.docmMicrosoft Word document with macros
application/vnd.ms-works.wps .wksMicrosoft Works document
application/vnd.ms-xpsdocument.xps .oxpsOpen XML Paper Specification
application/vnd.oasis.opendocument.base.odbOpenDocument database
application/vnd.oasis.opendocument.formula.odfOpenDocument formula
application/vnd.oasis.opendocument.graphics.odgOpenDocument drawing
application/vnd.oasis.opendocument.presentation.odpOpenDocument presentation
application/vnd.oasis.opendocument.spreadsheet.odsOpenDocument spreadsheet
application/vnd.oasis.opendocument.spreadsheet-template.otsOpenDocument spreadsheet template
application/vnd.oasis.opendocument.text.odtOpenDocument text document
application/vnd.oasis.opendocument.text-template.ottOpenDocument text template
application/vnd.openofficeorg.extension.oxtOpenOffice.org extension · unofficial
application/vnd.openxmlformats-officedocument.presentationml.presentation.pptxMicrosoft PowerPoint presentation, Open XML
application/vnd.openxmlformats-officedocument.presentationml.slideshow.ppsxMicrosoft PowerPoint slideshow, Open XML
application/vnd.openxmlformats-officedocument.presentationml.template.potxMicrosoft PowerPoint template, Open XML
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.xlsxMicrosoft Excel workbook, Open XML
application/vnd.openxmlformats-officedocument.spreadsheetml.template.xltxMicrosoft Excel template, Open XML
application/vnd.openxmlformats-officedocument.wordprocessingml.document.docxMicrosoft Word document, Open XML
application/vnd.openxmlformats-officedocument.wordprocessingml.template.dotxMicrosoft Word template, Open XML
application/vnd.quark.quarkxpress.qxdQuarkXPress document
application/vnd.rar.rarRAR archive
application/vnd.recordare.musicxml.mxlMusicXML score, zipped
application/vnd.recordare.musicxml+xml.musicxmlMusicXML score
application/vnd.sun.xml.calc.sxcOpenOffice.org 1.0 spreadsheet · unofficial
application/vnd.sun.xml.writer.sxwOpenOffice.org 1.0 text document · unofficial
application/vnd.tcpdump.pcap.pcap .capPacket capture
application/vnd.visio.vsdMicrosoft Visio drawing, legacy
application/vnd.wordperfect.wpdWordPerfect document
application/wasm.wasmWebAssembly binary
application/widget.wgtW3C widget package
application/wsdl+xml.wsdlWeb Services Description Language
application/x-3ds.3dsAutodesk 3D Studio mesh · unofficial
application/x-7z-compressed.7z7-Zip archive · unofficial
application/x-abiword.abwAbiWord document · unofficial
application/x-apple-diskimage.dmgApple disk image · unofficial
application/x-bat.batWindows batch file · unofficial
application/x-bibtex.bibBibTeX bibliography · unofficial
application/x-bittorrent.torrentBitTorrent metadata · unofficial
application/x-blender.blendBlender scene · unofficial
application/x-bzip.bzBzip compressed data · unofficial
application/x-bzip2.bz2Bzip2 compressed data · unofficial
application/x-chess-pgn.pgnPortable Game Notation · unofficial
application/x-chrome-extension.crxChrome extension · unofficial
application/x-cpio.cpioCpio archive · unofficial
application/x-cue.cueDisk image descriptor sheet · unofficial
application/x-dvi.dviTeX device-independent output · unofficial
application/x-esri-shape.shpESRI shapefile geometry · unofficial
application/x-fictionbook+xml.fb2FictionBook e-book · unofficial
application/x-font-type1.pfb .pfa .pfmPostScript Type 1 font · unofficial
application/x-gnumeric.gnumericGnumeric spreadsheet · unofficial
application/x-hdf.hdf .h5Hierarchical Data Format 5 · unofficial
application/x-httpd-php.php .phtmlPHP script · unofficial
application/x-indesign.inddAdobe InDesign document · unofficial
application/x-ipynb+json.ipynbJupyter notebook · unofficial
application/x-iso9660-image.isoISO 9660 disk image · unofficial
application/x-keepass2.kdbxKeePass 2 database · unofficial
application/x-lz4.lz4LZ4 compressed data · unofficial
application/x-lzh-compressed.lzh .lhaLHA archive · unofficial
application/x-lzip.lzLzip compressed data · unofficial
application/x-lzma.lzmaLZMA compressed data · unofficial
application/x-mach-binary.dylibMach-O binary · unofficial
application/x-mimearchive.mhtml .mhtMHTML web page archive · unofficial
application/x-mobipocket-ebook.mobi .prcMobipocket e-book · unofficial
application/x-ms-reader.litMicrosoft Reader e-book · unofficial
application/x-ms-shortcut.lnkWindows shortcut · unofficial
application/x-msaccess.mdb .accdbMicrosoft Access database · unofficial
application/x-msdownload.exe .dll .msiWindows executable or library · unofficial
application/x-mswrite.wriWindows Write document · unofficial
application/x-ndjson.ndjson .jsonlNewline-delimited JSON · unofficial
application/x-netcdf.nc .cdfnetCDF data · unofficial
application/x-ns-proxy-autoconfig.pacProxy auto-config script · unofficial
application/x-nzb.nzbNZB newsgroup download list · unofficial
application/x-parquet.parquetApache Parquet columnar data · unofficial
application/x-pem-file.pem .keyPEM certificate or key · unofficial
application/x-pkcs12.p12 .pfxPKCS #12 key store · unofficial
application/x-redhat-package-manager.rpmRPM package · unofficial
application/x-research-info-systems.risRIS bibliographic citation · unofficial
application/x-sharedlib.soUnix shared library · unofficial
application/x-shockwave-flash.swfAdobe Flash movie · unofficial
application/x-spss-por.porSPSS portable data · unofficial
application/x-spss-sav.savSPSS data file · unofficial
application/x-sqlite3.sqlite .sqlite3 .db3SQLite database · unofficial
application/x-stuffit.sitStuffIt archive · unofficial
application/x-tar.tarTar archive · unofficial
application/x-tex.texTeX source · unofficial
application/x-vhd.vhd .vhdxHyper-V virtual disk · unofficial
application/x-www-form-urlencoded—HTML form query encoding
application/x-x509-ca-cert.crt .derX.509 certificate
application/x-xpinstall.xpiFirefox add-on · unofficial
application/x-xz.xzXZ compressed data · unofficial
application/xaml+xml.xamlExtensible Application Markup Language · unofficial
application/xhtml+xml.xhtml .xhtXHTML document
application/xliff+xml.xliffXML Localization Interchange File Format
application/xml.xmlExtensible Markup Language
application/xml-dtd.dtdXML document type definition
application/xquery.xqXQuery source · unofficial
application/xslt+xml.xsl .xsltExtensible Stylesheet Language Transformations
application/xspf+xml.xspfShareable Playlist Format · unofficial
application/yaml.yaml .ymlYAML document
application/zip.zipZIP archive
application/zstd.zstZstandard compressed data
audio/aac.aacAAC audio
audio/aiff.aif .aiff .aifcAudio Interchange File Format · unofficial
audio/amr.amrAdaptive Multi-Rate audio
audio/basic.au .sndμ-law audio
audio/flac.flacFLAC audio
audio/matroska.mkaMatroska audio
audio/midi.mid .midi .rmiMIDI music · unofficial
audio/mp4.m4a .mp4aMPEG-4 audio
audio/mpeg.mp3 .mpgaMP3 audio
audio/ogg.oga .ogg .spxOgg audio
audio/opus.opusOpus audio
audio/vnd.dts.dtsDTS audio
audio/vnd.rn-realaudio.ra .ramRealAudio · unofficial
audio/wav.wavWAV audio · unofficial
audio/webm.webaWebM audio · unofficial
audio/x-caf.cafApple Core Audio file · unofficial
audio/x-dsf.dsfDSD stream file · unofficial
audio/x-it.itImpulse Tracker module · unofficial
audio/x-mod.modProTracker module · unofficial
audio/x-mpegurl.m3uM3U playlist · unofficial
audio/x-ms-wma.wmaWindows Media audio · unofficial
audio/x-s3m.s3mScream Tracker 3 module · unofficial
audio/x-scpls.plsPLS playlist · unofficial
audio/x-wavpack.wvWavPack audio · unofficial
audio/x-xm.xmFastTracker II module · unofficial
font/collection.ttcTrueType font collection
font/otf.otfOpenType font
font/sfnt—SFNT font, TrueType or OpenType
font/ttf.ttfTrueType font
font/woff.woffWeb Open Font Format
font/woff2.woff2Web Open Font Format 2
image/apng.apngAnimated PNG
image/avif.avif .avifsAV1 Image File Format
image/bmp.bmpWindows bitmap image
image/emf.emfWindows Enhanced Metafile
image/gif.gifGIF image
image/heic.heicHEIF image, HEVC coded
image/heif.heifHigh Efficiency Image File Format
image/jp2.jp2JPEG 2000 image
image/jpeg.jpg .jpeg .jpe .jfifJPEG image
image/jxl.jxlJPEG XL image
image/png.pngPNG image
image/svg+xml.svgScalable Vector Graphics
image/tiff.tif .tiffTIFF image
image/vnd.adobe.photoshop.psdAdobe Photoshop document
image/vnd.dwg.dwgAutoCAD drawing
image/vnd.dxf.dxfAutoCAD interchange format
image/vnd.microsoft.icon.icoIcon or cursor image (registered name)
image/vnd.wap.wbmp.wbmpWireless bitmap image
image/webp.webpWebP image
image/wmf.wmfWindows Metafile
image/x-adobe-dng.dngAdobe Digital Negative raw image · unofficial
image/x-canon-cr2.cr2Canon raw image · unofficial
image/x-emf.emfWindows Enhanced Metafile, deprecated name
image/x-exr.exrOpenEXR image · unofficial
image/x-icon.ico .curIcon or cursor image (unofficial name) · unofficial
image/x-nikon-nef.nefNikon raw image · unofficial
image/x-pcx.pcxPCX bitmap image · unofficial
image/x-portable-anymap.pnmPortable anymap · unofficial
image/x-portable-bitmap.pbmPortable bitmap · unofficial
image/x-portable-graymap.pgmPortable graymap · unofficial
image/x-portable-pixmap.ppmPortable pixmap · unofficial
image/x-sony-arw.arwSony raw image · unofficial
image/x-tga.tgaTruevision TGA image · unofficial
image/x-wmf.wmfWindows Metafile, deprecated name
image/x-xcf.xcfGIMP image · unofficial
message/rfc822.emlEmail message
model/gltf+json.gltfglTF 3D model
model/gltf-binary.glbglTF 3D model, binary
model/mesh.msh .meshFinite-element mesh
model/obj.objWavefront OBJ geometry
model/stl.stlSTL 3D print
model/vnd.collada+xml.daeCOLLADA 3D model
model/vnd.usdz+zip.usdzApple USDZ 3D scene
multipart/byteranges—HTTP partial content ranges
multipart/form-data—HTML form upload encoding
text/calendar.ics .ifbiCalendar event or free/busy list
text/css.cssCascading Style Sheets
text/csv.csvComma-separated values
text/event-stream—Server-sent events stream · unofficial
text/html.html .htmHTML document
text/javascript.js .mjsJavaScript (ECMAScript)
text/markdown.md .markdownMarkdown document
text/n3.n3RDF in Notation 3
text/plain.txt .text .logPlain text
text/tab-separated-values.tsvTab-separated values
text/troff.man .t .tr .roffTroff or man page source
text/turtle.ttlRDF in Turtle syntax
text/typescript.tsTypeScript source code · unofficial
text/vcard.vcf .vcardvCard contact
text/vtt.vttWebVTT subtitles or captions
text/x-asciidoc.adoc .asciidocAsciiDoc document · unofficial
text/x-c.c .hC source code · unofficial
text/x-c++.cpp .cc .cxx .hpp .hhC++ source code · unofficial
text/x-csharp.csC# source code · unofficial
text/x-diff.diff .patchUnified diff · unofficial
text/x-go.goGo source code · unofficial
text/x-groovy.groovyGroovy source code · unofficial
text/x-haskell.hsHaskell source code · unofficial
text/x-java-source.javaJava source code · unofficial
text/x-kotlin.kt .ktsKotlin source code · unofficial
text/x-less.lessLess style sheet · unofficial
text/x-lua.luaLua source code · unofficial
text/x-opml.opmlOutline Processor Markup · unofficial
text/x-perl.pl .pmPerl source code · unofficial
text/x-protobuf.protoProtocol Buffers schema · unofficial
text/x-python.py .pywPython source code · unofficial
text/x-rst.rstreStructuredText · unofficial
text/x-ruby.rbRuby source code · unofficial
text/x-rust.rsRust source code · unofficial
text/x-sass.scss .sassSass style sheet · unofficial
text/x-scala.scalaScala source code · unofficial
text/x-swift.swiftSwift source code · unofficial
text/xml.xmlExtensible Markup Language, same as application/xml
video/3gpp.3gp .3gpp3GPP video
video/3gpp2.3g23GPP2 video
video/h264.h264H.264 elementary stream
video/hevc.hevc .h265H.265/HEVC elementary stream · unofficial
video/matroska.mkvMatroska video
video/matroska-3d.mk3dMatroska stereoscopic 3D video
video/mp2t.ts .m2t .mtsMPEG transport stream
video/mp4.mp4 .m4vMPEG-4 video
video/mpeg.mpeg .mpg .mpe .m1v .m2vMPEG-1 or MPEG-2 video
video/ogg.ogvOgg video
video/quicktime.mov .qtQuickTime movie
video/vnd.rn-realvideo.rvRealVideo · unofficial
video/webm.webmWebM video · unofficial
video/x-dv.dvDigital video · unofficial
video/x-f4v.f4vFlash video, H.264 · unofficial
video/x-flv.flvFlash video · unofficial
video/x-m2ts.m2tsBlu-ray MPEG-2 transport stream · unofficial
video/x-mng.mngMultiple-image Network Graphics, animated · unofficial
video/x-ms-asf.asf .asxAdvanced Streaming Format · unofficial
video/x-ms-wmv.wmvWindows Media video · unofficial
video/x-msvideo.aviAVI video · unofficial

Types marked unofficial are common but not in the IANA registry. Text types are served as Content-Type: type/subtype; charset=utf-8; everything else has no charset.

Runs in your browser. Nothing you enter is sent anywhere.