You can run your private JavaScript server side e.g. using ASP JScript.NET
<% WebService Language="JScript" Class="MyClass" %>
You can put the hidden functionality on the server and call it via AJAX in the non hidden part of the code on the client.
you can also use
<script runat="server">
or if you're not using a Microsoft platform you might consider Mozilla Rhino