Javascript best practices?
erlanger: * Comment with JSDoc style* Auto-build docs and script for development and production environemnts (easy to concatenate and then pipe this to YUI Compressor)* Use an MVC project organization or something like-minded. You can't just throw files representing widgets around.* Write unit tests. JSUnit and SrewUnit (I prefer the latter) work well for this.* Format your code nicely (this goes for any code but I find a ton of terribly formatted JS)* Use one common library for any core object prototype changes (on Element, Array, Function, etc.) and don't modify them further.* JSLint code you're unsure about.* The best way to dynamically load code is just to write script tags to the document.A few style-concerned ones...* Don't use the module pattern. It's rarely appropriate, hiding methods does nobody good, just use a closure.* Only create elements when absolutely necessary and destroy ones that you will no longer use. There's no garbage collector in that regard.* Use a routing system to manipulate and read document.location.hash (and the browser history) so that pages have real URLs and navigate like webpages.* Callbacks and delegates are great, they should be used all over the place.* Use events and listeners to connect the parts of your app.