18 January 2011

jQuery part 2: JavaScript

By Andrew Clifford

JavaScript overcomes the limitations of plain HTML and CSS websites, but is difficult to do well.

Last week I covered how the basic web technologies of HTML and CSS can produce elegant websites, but do not fully meet the requirements for the levels of dynamic behaviour that people expect.

The limitations of HTML and CSS are:

These limitations can be overcome using JavaScript. JavaScript is a programming language supported by all major browsers. JavaScript scripts are typically written in separate files, and referenced by the HTML file, similar to how CSS files are referenced.

JavaScript can modify how the browser behaves. It can:

JavaScript is very powerful, but it introduces a load of new problems. JavaScript is difficult to do well. Different browsers work differently, providing subtly different ways to interact with the HTML and with the user.

As well as these basic problems, the whole approach to writing JavaScript is hard. If you want to modify the structure, you have to navigate through the HTML to find the parts you need to modify. If you want to modify the behaviour of the browser, you have to create code to respond to specific events, and then navigate through the HTML and attach the code to the bits of the page that can trigger the events. This is hard on a complicated page, where you may want to combine multiple events and multiple modifications.

Next week I will cover how jQuery overcomes these problems with JavaScript.