title: How to make Laravel return a View's "Content-Type" header as "application/javascript"?
body: <p>I'm trying to output a dynamic javascript file for inclusion from external websites with the <code>[script src=""]</code> tag. As the view is using the Blade engine, it's rendered as <code>text/html</code>. </p>
  
  <p>I'd like the <code>Content-Type</code> header to be set to <code>application/javascript</code> for this view only to avoid Chrome bugging me with messages like "<code>Resource interpreted as Script but transferred with MIME type text/html:</code>"</p>
  
  <p>My controller:</p>
  
  <pre><code>{
      // ...
      return View::make('embedded')-&gt;with('foo', $foo);
  }
  </code></pre>
  
  <p>The view itself:</p>
  
  <pre><code>&lt;?php
  header('Content-Type: application/javascript; charset=UTF-8', true);
  ?&gt;(function(jQuery) {
      // append stylesheets to &lt;head&gt;
      var file;
      // ...
  })(jQuery);
  </code></pre>
  
  <p>I've found that I can use <code>header()</code> in my view to add custom headers like <code>X-Content-Type</code> as expected, however when I try to redefine the <code>Content-Type</code> header it doesn't seem to do anything even with the <code>replace</code> parameter set as <code>true</code>.</p>
  
  <p>I'm surely missing something obvious here, would appreciate your pointing it out to me :)</p>
  
  <p>Thanks a lot for your help</p>