I want to add source maps to my site, but I'd like to exercise some control over how they're served. What is an appropriate MIME type to use for them?
http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.2/jquery.min.map
with Content-Type: application/octet-stream
.http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.map
with Content-Type: application/json
)]}
to prevent them from being evaluated as actual JavaScript (and thus exposing cross-site scripting attacks). That makes the file invalid JSON and valid, but un-runnable JavaScript.To enable source maps in Google Chrome, go to Developer Tools, click the little cog icon, and then make sure that “Enable Javascript source maps” is checked. That's it.
Summary. MIME types enable browsers to recognize the filetype of a file which has been sent via HTTP by the webserver. As a result the browser is able to choose a suitable displaying method. Common MIME types are for example text/html for html-files or image/jpeg for jpeg-files.
application/json
is the best mimetype for sourcemap files.
application/octet-stream
might work well with browser devtools, however this mimetype is a signal to browsers to initiate a download. This may cause problems for tools like performance analysis tooling or JS exception tracking that attempt to make sense of the source maps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With