Resource interpreted as Script but transferred with MIME type text/plain - for local file
Solution 1
I figured it out!
The Visual Studio installer must have added an errant line to the registry.
open up regedit
and take a look at this registry key:
See that key? The Content Type key? change its value from text/plain to text/javascript.
Finally chrome can breathe easy again.
I should note that neither Content Type nor PercievedType are there by default on Windows 7, so you could probably safely delete them both, but the minimum you need to do is that edit.
Anyway I hope this fixes it for you too!
Solution 2
I tried fixing this problem using this method but it didn't work for me.
My problem was that IIS manager didn't have MIME types in HTTP Features.
I was able to turn it on by enabling Static Context via...
--> Control Panel
--> Programs
--> Turn Windows features on or off
--> Internet Information Services
--> World Wide Web Services
--> Common HTTP features
--> [X] Static Content.
After this, MIME types appeared and everything started working again.
batzkoo
Updated on February 03, 2020Comments
-
batzkoo over 4 years
I'm getting a "Resource interpreted as Script but transferred with MIME type text/plain" warning in Google Chrome when including a local script file.
I know the problem appears when loading a file from a server or through ajax which most often depends on wrong headers being set.
The weird thing is that I get this warning even though it is run from a local folder:
file:///C:/test/foo.html
This happens only in Chrome with the most basic html there is:
<!DOCTYPE html> <html> <head> <script type="text/javascript" src="bar.js"></script> </head> <body> </body> </html>
bar.js is also as simple as it can get:
function hello() {}
I've tried adding a meta tag:
<meta http-equiv="content-script-type" content="text/javascript">
and tested with other doctypes but nothing seems to help.
This obviously isn't a real issue since the scripts still work fine, but I'm working on a large project and currently have around 150 scripts included. It therefore makes it difficult to see when an actual warning occurs in between them.
Everything works fine when I run the file on a server, locally or remote.
Any ideas on why chrome is annoying me with this?
-
batzkoo almost 12 yearsWell done you! for finding the solution to this annoyance. I didn't delete the key but instead changed the data value to text/javascript. Thanks!
-
Simon Sarris almost 12 yearshaha I changed it to text/script and it didn't work, maybe I should have tried text/javascript!
-
Zoltan over 11 yearsThanks for the Solution ! I had the same problem... Actually with MIME type plain/text for me the javascript code had thrown errors. I had some strings (in an array) containing letters found in UTF-8 encoding seen in east-europian languages like "ő". "Gergő" is nice comon Hungarian first name. The errors also has gone thanks god, since I could not run my code - but I did not investigate this further.
-
Pakman over 11 yearsWow, how did you discover this solution?
-
Simon Sarris over 11 years@Pakman I had the problem one day, then I bought a new computer and didn't have the problem. Then, when I installed Visual Studio 2012 I noticed that it re-appeared, so I figured that was the culprit. I figured it changed something in the file associations of the registry because all my
.js
files had.txt
looking icons, so I went to make sure they were associated with the right data type. They weren't! -
user198552 over 11 yearsThe registry location is HKEY_CLASSES_ROOT\.js\ (I had to search myself!) Edit: - Because I am getting blind and didn't saw the arrows in the image itself :)
-
Teepeemm about 10 yearsBut OP's problem is that the page loads correctly, but he still gets an error message. This doesn't seem to change anything.