Andrew Connell has some good coverage on this issue in his book Sharepoint 2007 WCM Development. In the code downloads for his book he offers a control which suppresses the javascript files as necessary for authorised and anonymous users.
The code download is here, and Chapter 19 is what you need to reference;
www.wrox.com/.../...rver-2007.productCd-0470224754,descCd-DOWNLOAD.html
There's an article on the topic by a different author here;
msdn.microsoft.com/.../bb727371.aspx
If you're sold on the usefulness of Andrew Connells book it can be obtained here;
www.amazon.com/.../0470224754
It goes into much more depth than I can here (wouldn't be right to quote it verbatim!)