Javascript Tips


Javascript – the ugly duckling.

For years, Javascript was my pet hate. I avoided it wherever possible. Sure it was good for quick form validation and alerts, but it was a horror to work with: messy, unstructured, unwieldy, and difficult to debug.

I was not alone.

Today Javascript is my new love.

So, what has changed?

Let there be AJAX

Javascript itself has not changed; the way we use it has.

Creative programmers started doing things with Javascript no-one had dreamed possible. AJAX applications (Gmail, for instance) started to appear and reveal the graceful swan that lies within our much maligned Javascript.

AJAX, or Asynchronous Javascript and XML, is a programming style used to create web applications that offer very fast user interaction and UI updates. Instead of refreshing the entire web page for every user action, bits of XML are sent between the browser and server. DOM elements are updated dynamically.

Javascript powers all of this on the client. But not the old-style Javascript from the spagetti coding days. These applications require coding that is better thought-out and more disciplined, using object-oriented techniques and design patterns. (More on those perhaps in later articles.)

Javascript has been able to make this jump because of key qualities it has had all along:

  • It allows a form of Object-Oriented programming
  • It is implemented mostly uniformly across browsers. (We have tools to overcome the browser inconsistencies that do exist)