by erlanger · 17y ago · 0 comments
* 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.
rules on serverside are a bit different. especially the module pattern is a must there.
in the future you might be able to pick one of those module loaders http://wiki.commonjs.org/wiki/CommonJS
Just curious. For large scale projects, do you suggest building on top of existing javascript libraries (i.e. prototype, jQuery, mootools, etc)?
In my opinion, jQuery is suitable for progressive enhancement but not for dedicated apps.
* +1 on not using the module pattern.