I do not really like to parse all .js files as php. I would suggest using the .htaccess Rewrite directive to map .js files to your php script.
RewriteRule /phpjs/.* /phpjs/js.php
Then add
header("Content-Type: text/javascript");
to your php output.
source share