Spring cleaning old code

Here is a little tip for cleaning up old code.  I was looking at a new client’s website recently and saw they had some horrible old JavaScript to produce a nice fade effect when a visitor’s mouse was rolled over the menu bar.

Now for the last 5 years or so this sort of effect has been achievable using standard style sheet css. However, unless someone bothers to remove the old stuff it simply sits there.

Why fix code if it isn’t broken?

The answer is that replacing JavaScript rollovers with equivalent css will please both visitors and search engines.

Simply put, the result will be quicker load times. This pleases people because they don’t have to wait around for a site to load and pleases search engines because they look at load times when assigning quality scores to pages.

Thirdly, css is much more likely to work than JavaScript in the myriad of mobile phone and tablet configurations that people are using to access web pages these days.

So, do yourself a favour and if your website was built more than 5 years ago, get someone to check it for old bloated code that is out of date.