MIME type for javascript - is now text/javascript

I recently switched to {{ .MediaType }} instead of hard-coding it, and I noticed that Hugo (v0.104.3) is returning application/javascript. I checked the documentation, and it is listed as application/javascript.

I’ve always used text/javascript so I thought the new standard is application/javascript.

However, the different standards bodies finally settled on one and deprecated everything else only this year, back in May 2022.

Here are the relevant documents I found:

The following MIME types are now deprecated/obsolete:

  • application/ecmascript
  • application/javascript
  • application/x-ecmascript
  • application/x-javascript
  • text/ecmascript
  • text/javascript1.0
  • text/javascript1.1
  • text/javascript1.2
  • text/javascript1.3
  • text/javascript1.4
  • text/javascript1.5
  • text/jscript
  • text/livescript
  • text/x-ecmascript
  • text/x-javscript

To quote:

For both categories, the “Published specification” entry for the media types is updated to reference. In addition, a new file extension of .mjs has been added to the list of file extensions with the restriction that contents should be parsed using the Module goal. Finally, the specification uses “text/javascript” as the default media type of ECMAScript when preparing script tags; therefore, “text/javascript” intended usage has been moved from OBSOLETE to COMMON.

This is minor (from my perspective) especially since it was only a recent change. But maybe we can update Hugo’s MIME types to reflect the May 2022 decision to settle on text/javascript?



But also not that it’s possible to redefine Hugo’s MIME types in your site config.

1 Like