Oh, you mean that it has template conditionals and PHP variables (javascript also has it's own variables, so I didn't understand what you were getting at).
What you can do is find all the PHP variables it uses, then put them in a template that outputs js code that simply sets a js variable to that value. Then change the js code (that you're trying to move to a file) to use the js variables, and change the template conditionals to js 'if' statements.
Another way would be to set the src of the scirpt tag to a php file that renders the template and returns the js. But that way you wouldn't be able to allow the browser to cache the output which I guess is the point of doing this.
Edit: The headinclude template already has a section that sets js variables, it looks like this:
Code:
<script type="text/javascript">
<!--
var SESSIONURL = "$session[sessionurl_js]";
var SECURITYTOKEN = "$bbuserinfo[securitytoken]";
var IMGDIR_MISC = "$stylevar[imgdir_misc]";
var vb_disable_ajax = parseInt("$vboptions[disable_ajax]", 10);
// -->
</script>
You could add yours there, but you'd probably want to have some sort of template conditional around it so you weren't putting it in every page (like maybe <if condition="THIS_SCRIPT == 'misc'">)