As web pages become more and more like applications, code performance becomes more and more important. This article looks at a number of performance issues to avoid, in EcmaScript, DOM and AJAX requests. Covers eval, the with keyword, try/catch in performance-critical code, global variables, implicit object conversion, string concatenation, primitive operations over function calls, repainting and reflowing documents, modifying elements, using XPath.
Matt Kruse's JavaScript Toolbox presents a number of excellent best practice ideas including: using var, feature detection, when to use square bracket notation, avoiding eval, referencing forms and form elements, avoiding the with keyword, using onclick instead of JavaScript pseudo-protocol, using unary + to type convert to numbers, avoiding document.all, not using HTML comments in script blocks, avoid cluttering the global namespace, avoiding prototype.js, avoiding synch Ajax calls, using JSON and the correct way to use script tags