Dunno man, there's too many items left in the dark here.
Such as...
How are your pages structured?
How much code is encapsulated in objects/functions?
How dependant is your javascript on PHP?
...just to name a couple.
What you could try is to rip out all your javascript stuff into seperate files and then
leave it as raw javascript and where you need php output, just wrap it up inside an opening/closeing pair like so...
<? echo $var; ?>
Then to get the javascript where you want it,
just include it in the appropriate sections of your php scripts...
<?
include('javascript_section.inc');
?>
And it WILL parse the PHP but NOT the javascript.