Прямо от http://php.net/header
<?php
// There is contention over if this MIME type is right, but just use it for now.
header('Content-type: text/javascript');
header('Content-Disposition: attachment; filename="file.js"');
readfile('file.js'); // Echo the file
?>
ПРИМЕЧАНИЕ: это должно быть сделано перед любым другим выводом (и может быть единственным на странице, если только вы не хотите другого вывода в вашем файле).