Cleaning up your javascripts

Search engines in general does not consider javascript code in its ranking. In fact Google has just started reading javascript code a few months ago just to monitor websites with sneaky redirects which is against their policy.
So how do we optimize our site with regards to our javascript code?
The best way is to put all javascript code in an external file. This keeps your html code clean and without unnecessary code that can affect code to content ratio and your keyword densities.
If you are using some form of javascript redirect, I suggest better delete that code and use some static link instead. Google is getting better and better in analyzing javascript code. It is just a matter of time before all kinds of automatic javascript redirects will be penalized.