Best practices for writing javascript widgets [closed] Best practices for writing javascript widgets [closed] javascript javascript

Best practices for writing javascript widgets [closed]


I am a big fan of Peter Michaux's guide on how he writes javascript widgets

Also useful are Christian Heilmann's script configuration and the module pattern

Those are generic javascript articles and aren't specific to a single library

Other useful tricks are things like wrapping your code in an anonymous function to stop it interfering with other global libraries.

(function() {    //Your code goes in here})();

Regarding errors and best practice, John Resig has an interesting article on javascript strict that isn't in yet, but does have some handy information on the sort of things you should be avoiding.

If you're still coming to terms with scoping within your objects, then you might find this article on private and public variables useful as well a a bit more technical definition by Douglas Crockford

Finally, remember to run your completed code through a code quality tool