OK, well "hiding" is certainly not the right
word for that.
So you are asking if you can move the JavaScript out of the page and into a separate file? If so, then yes. Create a file containing the script, give it a file type of .js, and use the src attribute on the script tag to reference it.
Example:
[Moved to the HTML forum.]