title: Specify mime type of php file as application/javascript
body: <p>Is it possible to specify the MIME type of a PHP file as <code>application/javascript</code>? I have a PHP file that outputs some JavaScript. When strict MIME type checking is enabled, the browser reports an error:</p>
  
  <blockquote>
    <p>"Refused to execute script from *.php' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled."</p>
  </blockquote>
  
  <p>Adding this to the PHP file doesn't help:</p>
  
  <pre><code>header("Content-type: application/javascript");
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>&lt;?
    header('Content-Type: application/javascript');
    include ("../admin/config.php");
    include ("../custom_functions.php");
  ?&gt;
  var availableTags = ["BBCD"
  &lt;? 
    $prods=decode_prods();
    foreach($prods as $key=&gt;$val){  
  ?&gt;
  , "
  &lt;?
    $prods[$key][name] = preg_replace("/(\015\012)|(\015)|(\012)/","",$prods[$key][name]); 
    trim($prods[$key][name]);
    $prods[$key][name]= str_replace("&amp;", "and", $prods[$key][name]);
    $prods[$key][name]= str_replace('"', '', $prods[$key][name]);
    echo $prods[$key][name];
  ?&gt;
  "
  &lt;? } ?&gt;
  ];
  </code></pre>
  
  <p>I tried adding this to <code>.htaccess</code> after reading <a href="https://stackoverflow.com/questions/15628826/htaccess-setting-the-mimetype-for-a-single-file">this post</a> - but it didn't help.</p>
  
  <pre><code>&lt;Files /js/auto.php&gt;
  AddType application/javascript .js
  &lt;/Files&gt;
  </code></pre>