Laniakea Laniakea - 6 months ago 25
PHP Question

Scripts gets interpreted as Stylesheet but transferred with MIME type text/html

I'm getting two console warnings in Chrome:

Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://domain/". domain/:11
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://domain/". domain/:11


On line 11, I have:

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>


Here's all of the code for the head section:

<head>
<meta charset="UTF-8">
<title>Laoautod</title>

<meta http-equiv = "Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="css/base.css">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<script type="text/javascript" src="js/center.js"></script>
<script type="text/javascript">
function displayResult()
{
var x=document.getElementById("checkbox").defaultChecked;
alert(x);
}
</script>
<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'accountID']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>
</head>


The HTML code is inside index.php file so I added
header('Content-type: text/css');
in the beginning of the pages script. I also included
AddCharset utf-8 .css .js
and
AddType text/css .css
in the
.htaccess
file but no luck loosing the warnings.

What exactly is causing this and how do you get rid of the warnings?

Answer

Okay, I found the problem.

The reason I was getting warnings was because I was using @import in base.css to bring in scripts that were not in their location. To be precise, I was missing 2 scripts, so presumably that's the reason I got 2 warnings.