Some signs that a JavaScript Script was Badly Written

  • No object detection, just navigator.appName and/or navigator.userAgent detection.
  • Code that is written only for IE4+ and/or Netscape 4. One can tell this by checking to see if the code uses IE's document.all and/or Netscape 4's document.layers without using DOM1+'s document.getElementById()
  • document.all is used to detect if a browser is IE. To work with legacy web pages many other browsers support document.all, so you should only test for it if you intend to use it to support browsers that don't properly support the DOM1+ methods that have rendered it obsolete.
  • javascript: appears in places other than as part of a URL. An example of javascript: used appropriately is: <a href="javascript:var someJavaScriptCode=true;">
  • with(object) is used. It is slow and can cause unexpected behavior, and you can easily get its benefits without its problems by assigning the object to a new variable.
  • eval() is used more than once or twice. It's slow and it is almost always not needed.
  • Some Common JavaScript Mistakes
Last update: 2006-10-06