I\'m trying to output a dynamic javascript file for inclusion from external websites with the [script src=\"\"] tag. As the view is using the Blade engine, it\'
[script src=\"\"]
In Laravel 5.4 you can do this:
$contents = view('embedded')->with('foo', $foo); return response($contents)->header('Content-Type', 'application/javascript');
BTW, there is no need to set the header in the view.