Friday, December 12, 2008

How can Javascript deliver the goods for SEO

I seem to have stimulated a good amount of interest amongst our tech team following on from my post on JavaScript. To be clear there are two good reasons to keep an eye on JavaScript development - Search engine optimisation and Social Media.

In SEO the key is all about separation - let not the JavaScript get near your content. In Social Media, the more you use it the better your site - a real dichotomy. There are two ways to employ JavaScript on a site and they are very similar to the way you deal with CSS:

  • Use external files to hold the code

  • Progressive Enhancement

The first item is self explanatory, the second is a classic technique that we use in SEO where we want a specific action to occur. The action would depend on whether JavaScript was turned on or turned off. If JavaScript was turned on then the JavaScript actions would occur, if JavaScript was turned off, then the user would simply see a standard hyperlink for example.

In Search engine optimisation terms; whether JavaScript is on or off, a search engine robot would simply see a link. In English terms; we build a page with solid code and build enhancements on top. If the enhancements fail, the page will not show an ugly error, simply a less good way of getting to the results we had intended.

Just in case you are thinking 'what possible use would that be to me?'. Well one instance could be that if you wanted to show your expert list of closely related sites that are stored in your Delicious account you could use Progressive Enhancement techniques on your web page.

As you would rather keep your list in Delicious, where you can add to it or modify it easily - rather than copy the list, you could place it on your web page with some clever JavaScript and keep it up to date through Delicious.

Your web page would use some JavaScript, (it would need to use JSON - activated through JavaScript because JavaScript works on calls to your own server and no elses) and if it all worked it would show the list you were hoping for. If it failed it would simply show a link to your Delicious account and your users would have to click off your page to go see the list - a lot less desirable - but at least it would not show an error. In the main of course it would work and when it did you would be certain that the list shown was the most up to date list and this would save you the trouble of maintaining the list.

In both cases I would be passing a link to my Delicious account and allowing my web page readers to get the information that I wanted to give them and if Javascript, JSON or Delicious failed, no one would know and my page would be unruffled.

As you can see Progressive Enhancement is a technique that is employed for usability as well as for SEO. Progressive Enhancement protects the integrity of your page and gives benefits to user. This is a real win win concept, that requires an understanding of JavaScript, and is a core component of Web 2.0 sites. So we need to keep an eye on JavaScript for the future.

It is only recently that JavaScript has returned to being considered again as a genuinely useful piece of code. As in the early days JAVA kept on failing and different browsers then had different flavours of JavaScript - as a result, lots of sites failed and helped to make the web the nightmare that it was back then...

Nowadays JavaScript has settled down and really is at the heart of Web 2.0. As Web developers, SEO specialists and consumers, we need to be aware of the benefits that JavaScript delivers to help make the web a more optimistic place.

No comments: