Here are some rules I constrain myself to, and that can be useful for others :
- Use good code conventions
- Check your code: JSLint (javascript tools bundle for textmate make it automatic)
- Minification of your code: JSMin
- GZIP the code, don’t obfuscate: Minification v. Obfuscation
You will effectively reduce errors and debugging time by following those advices.