[javascript] Debug message "Resource interpreted as other but transferred with MIME type application/javascript"

OK, I understand what the messages means, but I'm really not sure what's causing it. I'm using Safari and the Web Inspector on Mac OS X, by the way.

I've got the following in my document head:

<script src="http://local.url/a/js/jquery.js" type="text/javascript"></script>
<script src="http://local.url/a/js/jquery.inplace.js" type="text/javascript"></script>

jquery.js is handled fine, but the other file causes the warning. It also seems that the javascript in this file never gets executed.

The file is being served via mod_deflate, so it is gzip encoded, but so is the other file.

Has anybody got any ideas what's causing this, or how to resolve it?

Cheers all, Gaz.

This question is related to javascript apache safari mime-types

The answer is


On APACHE

Append these MIME types to .htaccess in your root. I recommend the second line, as it may help prevent any future potential MIME interpretation warnings with CSS files.

AddType application/x-javascript .js
AddType text/css .css    

Restart Your Apache...

On NGINX

Add to your nginx.conf or your mime.types import file (Recommended Method). Add any or all as needed/relevant.

types {
    text/html                             html htm shtml;
    text/css                              css;
    text/xml                              xml;
    image/gif                             gif;
    image/jpeg                            jpeg jpg;
    application/x-javascript              js;
    application/rss+xml                   rss;
    text/plain                            txt;
    image/png                             png;
    image/tiff                            tif tiff;
    image/svg+xml                         svg svgz;
    image/webp                            webp;
    application/postscript                ps eps ai;
    application/pdf                       pdf;
    application/rtf                       rtf;
    application/vnd.ms-excel              xls;
    application/vnd.ms-powerpoint         ppt;
    application/msword                    doc;
    application/x-shockwave-flash         swf;
    application/xhtml+xml                 xhtml;
    application/zip                       zip;
}

You need to use a tool to view the HTTP headers sent with the file, something like LiveHTTPHeaders or HTTPFox are what I use. If the files are sent from the webserver without a MIME type, or with a default MIME type like text/plain, that might be what this error is about.


It seems like a bug in Safari's cache handling policies.

Workaround in apache:

Header unset ETag
Header unset Last-Modified

An image with an empty "src" attribute generates this error under Windows-Chrome:

<img src="">

... whereas ...

<img>

... does not.

I arrived here because my ajax resultset was returning "src" data which was empty yet the img was still being inserted into the page.


I don't think it is a bug, Try adding the MIME type to your .htaccess file For instance, put or add the following content to your .htaccess file (which should be in the same place of your .js or above folders)

#JavaScript
AddType application/x-javascript .js

This solved my tree "Resource interpreted as other but transfered ... " warnings. Everytime you have that kind of warning it means you don't have enough info in your .htaccess file.

BTW1: Since you are modifying .htaccess file, make sure you restart your server.

BTW2: I also could clear same warnings for GIF files in Safari 4 with this:

#GIF
AddType image/gif .gif

BTW3: For other file types: see w3schools list or htaccess-guide


Another common cause of this error on the Mac is Apple's quarantine flag.

ls the directory containing the resource(s) in question. If you see the extended attribute indicator, i.e., the little @ symbol at the end of the permissions block (e.g. -rw-r--r--@ ) then the file could be quarantined.

Try ls -la@e and look for com.apple.quarantine

The following command will remove the quarantine:

xattr -d com.apple.quarantine /path/to/file

This warning appears because no default script type is specified. Try adding the following directive to your HTML file:

<meta http-equiv="content-script-type" content="text/javascript">

You can read more about default scripting specifications here: http://www.w3.org/TR/REC-html40/interact/scripts.html#h-18.2.2.1


Solved!

I have had this error for several days. It was driving me crazy because it didnt allow me to use firefox firebug's script debugger. Finally, my error was solved when I removed an empty url in a "background-image: url()" style property.

This has been so much a pain than I really hope somebody can use this advice.


I had the same issue with a css file instead of javascript. (using the xitami webserver)

what fixed for me was adding under the MIME section of xitami.cfg:

css=text/css


This bug seem to have resurfaced (Noticed it November 2010)

I think the WebKit bug reports involved are this one and this. Essentially it boils down to incorrect cache handling when doing an If-Modified-Since which get a 304 response.


I just got this and solved it locally on my mac. For some reason the javascript file in question had bad permissions. I noticed when I looked at it in firebug I was getting a 403. I hope that helps anyone.


It is because of the period in the file name. It is stupid, but anytime there is a period in the js file name you will get this error, and I have come across situations where it will actually prevent the js file from loading.


I found out that the naming of my css files was in conflict with the proxy filters

www.dating.com (which is not my site) was blocked and my css and js files were called dating.css and dating.js. The filter was blocking this. Maybe that is the case with some of you, working on corporates systems.


There seem to be many things that cause this. For me it was a lowercase rewrite rule in IIS. Changed the problem files (js and png) to lowercase and problem went away.


Examples related to javascript

need to add a class to an element How to make a variable accessible outside a function? Hide Signs that Meteor.js was Used How to create a showdown.js markdown extension Please help me convert this script to a simple image slider Highlight Anchor Links when user manually scrolls? Summing radio input values How to execute an action before close metro app WinJS javascript, for loop defines a dynamic variable name Getting all files in directory with ajax

Examples related to apache

Enable PHP Apache2 Switch php versions on commandline ubuntu 16.04 Laravel: PDOException: could not find driver How to deploy a React App on Apache web server Apache POI error loading XSSFWorkbook class How to enable directory listing in apache web server Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details How to enable php7 module in apache? java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient The program can't start because api-ms-win-crt-runtime-l1-1-0.dll is missing while starting Apache server on my computer

Examples related to safari

How to Inspect Element using Safari Browser What does the shrink-to-fit viewport meta attribute do? background: fixed no repeat not working on mobile Swift Open Link in Safari How do I make flex box work in safari? onClick not working on mobile (touch) window.open(url, '_blank'); not working on iMac/Safari HTML5 Video tag not working in Safari , iPhone and iPad NodeJS/express: Cache and 304 status code Video auto play is not working in Safari and Chrome desktop browser

Examples related to mime-types

Stylesheet not loaded because of MIME-type Is the MIME type 'image/jpg' the same as 'image/jpeg'? Proper MIME type for .woff2 fonts How to check file MIME type with javascript before upload? Correct MIME Type for favicon.ico? Right mime type for SVG images with fonts embedded Which mime type should I use for mp3 Correct mime type for .mp4 What does "Content-type: application/json; charset=utf-8" really mean? Add MIME mapping in web.config for IIS Express