I would add one more tip to Ozh’s: don’t pollute the global JavaScript namespace, especially with the over-used “$”. A number of JavaScript libraries use the dollar sign in different ways, so you can run into problems if, for example, you’re using jQuery but another plugin has loaded Prototype.

Fortunately, jQuery makes it easy to use “$” in a friendly way with other libraries. My favorite is to wrap jQuery-based code in something like the following, which employs $ outside of the global namespace and waits to execute the script until after the DOM has loaded.