Skip to content

Using JavaScript in your web site

Everyone loves to see funky effects and interactive elements when browsing the web.

Many of the features we see on web sites are made using JavaScript such as drag and drop features and the infamous Lightbox gallery. There are more and more JavaScript libraries to make coding even easier for developers. One of my favourites is JQUERY I find it pretty easy to use and there are many others using it which is great as doing a quick search you can find many snippets of code to help you.

The problem I encounter with sites using JavaScript is that they don’t think of users who don’t have JavaScript turned on. Should they be worrying about this? I believe they should be, more and more users now choose to have high security settings on their computers, especially in larger companies. Not only that, we have to make sure we try and cater for everyone in the accessible web of today.
Next time you visit a web site that has a feature running using JavaScript (if it is easy to recognise) try turning off JavaScript and see how it behaves. Web developers and Designers should be testing this for every site they create. Using the web developer toolbar for Firefox you can easily turn off JavaScript.

I have seen some sites that rely on the navigation to use JavaScript, which in my opinion is a big no no. There should be a fall back in case it doesn’t function. In these cases if JavaScript isn’t on then the user cannot navigate the site and this is really bad for any site.

For Developers, Internet Explorer 6 (ie6) is a problem and it is most definitely one of the things that drives me insane when building a site. For example when building a web site that has a dropdown menu it is a nightmare to accommodate ie6 without using JavaScript. It is possible to have a full CSS menu in ie6 but it creates more trouble than it is worth. It has to have lots more code and it involves CSS hacks which aren’t brilliant. Most will use a full CSS menu then have some JavaScript for Internet Explorer. Suckerfish is such an example. This is a great menu which is really tidy to use and will work in all browsers. I came across Kreisi which is a neat tutorial on how to use the suckerfish menu and also have some JavaScript to run the menu. This way if the user has JavaScript it will show a nice animated dropdown. If JavaScript is off it will revert to a CSS only menu. I really like this approach as it caters for almost everyone. Again ie6 will be an issue but if the user has JavaScript on it will show the animated menu. You then have a choice to make. Should we cater for ie6 when JavaScript is off? In my opinion as long as the site takes this into account by having page links to allow the user to navigate and also a sitemap then I think it is enough. This does depend on your user stats for your site; you may find that you have many users who use ie6 so this approach may not be the best solution for you.

The thing that gets to me is when a site uses JavaScript without a thought to what should happen if it is not on and whatever it is for doesn’t work. I have seen the JQUERY Cycle plugin recently used on some sites and when JavaScript is off it leaves the site with elements on the page that doesn’t do anything when you click them. In these circumstances these elements should be generated using JavaScript so at least if it is off they won’t b generated at all, thus leaving the user to get on and use the site without having to figure out why clicking on these elements that nothing happens.

This has been more of rant but I think it is an important part of any site that you are building to make sure you think about what should happen if JavaScript is turned off.

3 Comments (Add Yours)

  1. I agree that whilst JavaScript can enhance a site really well, we shouldn’t be ignorant and assume that everyone has JS running. With a bit of thought and logic, you can use JS to ensure that non JS users will still get the full benefit of the site.

  2. Hello, I found this blog article while searching for help with JavaScript. I have recently switched browsers from Safari to Firefox 3.2. Just recently I seem to have a issue with loading JavaScript. Everytime I browse page that needs Javascript, the site does not load and I get a “runtime error javascript.JSException: Unknown name”. I cannot seem to find out how to fix it. Any aid is greatly appreciated! Thanks

    • Sounds like you may have to reinstall Firefox is it only in Firefox that this happens if so they reinstall it.