rengel
rengel

Reputation: 453

Chrome says “Resource interpreted as script but transferred with MIME type text/plain.”, without server

This problem even arises, when there is no server access whatsoever. index.html is just accessing some locally stored JavaScript file:

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <script src="timeline.js"></script>
</head>

<body>
   <p>The Body</p>
</body>
</html>

When displayed in the browser, Chrome says:

Resource interpreted as Script but transferred with MIME type text/plain:  
file:///D:/Workspace/timeline/examples/engel-timeline/timelineReusable.v0.0/timeline.js". 

How can I suppress this message? (Adding a 'content-type' doesn't help!)

Upvotes: 1

Views: 13570

Answers (3)

Donkzilla
Donkzilla

Reputation: 1

The error also arises in this situation:

<script type="text/javascript" src="/livehelp/livehelp_js.php>

indicating that Chrome is the problem, the code is good. Chrome is wrongly blocking a script sent in a php file. The script is not blocked in other browsers except IE 11 and only when Apache directive Header set X-Content-Type-Options: "nosniff" is set.

Upvotes: 0

Pluto
Pluto

Reputation: 3026

I believe the reason for this is that your script is being loaded locally from your computer. It's directly accessing the file, so there are no request headers here, meaning there will be no MIME type that comes with your JS file.

If you upload your file on the Internet, then this will be fixed because it uses a different protocol (HTTP).

This problem should only end up happening when there is no server. If there is a server, then make sure you're using the server's URL, like http://localhost:80/timeline.js. And if that still is giving you a problem, then your server's MIME types need to be configured (though it's just a JavaScript file, so that shouldn't be a problem).

Upvotes: 6

mishik
mishik

Reputation: 10003

Try opening regedit: HKEY_CLASSES_ROOT\.js and either change or add string "Content Type" with value "text/javascript"

Upvotes: 5

Related Questions