- Separation of functionality (the "behavior layer") from a Web page's structure/content and presentation
I find this presentation to be a nice one to get the idea and get you started.
Minimisation is your friend (I’d recommend Google’s Closure Compiler: https://code.google.com/closure/compiler/). This will:
- remove white space
- remove comments
- minimise variable names
- even goes so far as to do simple dead code analysis and removal
Of course, your best approach is to make sure you’re writing as good quality code as possible in the first place!
I'm going to look at this from another point of view. Instead of trying to hide our dirty laundry, perhaps we should take the time to make sure what we push to our users is as clean as possible.
By trying to hide it away and make sure the user never sees it, how are we showing them that they can trust our code? How can we prove that what we are asking them to run isn't malicious?
As AJAX and jQuery become more and more popular, I feel that we are running out of excuses for having dirty laundry. These libraries make it nice and easy to provide a more advanced user experience. By taking some time, you can write very clean code that does some very powerful things.