getkirby / kirby

Kirby's core application folder
https://getkirby.com
Other
1.32k stars 168 forks source link

`Mime` class: replace "application/x-javascript" with "application/javascript" #4174

Closed sebastiangreger closed 2 years ago

sebastiangreger commented 2 years ago

I'm investigating a very odd and randomly occurring issue in the Panel of a Kirby site (not subject of this ticket; we occasionally get a Field type "text" does not exist error showing up, which disappears simply with a hard refresh) and one of the many paths I'm looking at is browser caching. Since I noticed the following – and got sucked into the rabbit hole that is MIME type specs – I thought I'd ask:

Looking at the DevTools Network tab, it appears that all Panel JS files are loaded with MIME type application/javascript, except for /media/plugins/index.js which is loaded with MIME type application/x-javascript.

Is there a reason Kirby's Mime class uses the non-standard application/x-javascript MIME type for JS files?

https://github.com/getkirby/kirby/blob/04127160ed1ab8dc277763cd8ba4ebc5a097bc18/src/Filesystem/Mime.php#L51

If not, may I suggest (secretly hoping this could be behind that odd error I am dealing with :wink:) changing this MIME type to application/javascript in compliance with RFC4329, which discourages use of the x- prefixed experimental MIME type:

Use of experimental and unregistered media types, as listed in part above, is discouraged. The media types,

  • application/javascript
  • application/ecmascript

which are also defined in this document, are intended for common use and should be used instead.

bastianallgeier commented 2 years ago