Too much JavaScript
Most design agencies use JavaScript for every project, says Line’s senior developer, Alistair Burns, and a lot of clients are perfectly happy with this. But how many consider users who can’t run it, such as government departments, public sector organisations and people with disabilities?
JavaScript offers developers a great deal. The fact that it runs in the browser keeps user experience fast and responsive. The ability to recognise user actions that HTML can’t allows more sophisticated interactions to be created. However, there’s now a tendency to include JavaScript and interaction where it’s not strictly necessary. There’s a feeling within design agencies that every site has to incorporate bells and whistles. If you’re creating something for a client, you need to include gee-whizz elements to show you’re really working for your money.
For the most part, many clients are perfectly happy with this. A shiny site, with clever forms and icons that change when the users mouse over them, means that they’re getting a lot of bang for their buck. After all, according to research carried out at the end of 2010 (www.w3schools.com/browsers/browsers_stats.asp), the vast majority of web browsers have JavaScript switched on, so you’re hitting everyone … right?
It’s easy to assume that everyone online is using an up-to-date browser, enjoys the clever interactive elements and can cope with the proliferation of JavaScript online. But consider the many people who either don’t have the latest browsers, or are within an environment in which JavaScript is disabled. This is not as rare as you may imagine.
Many government departments and public sector organisations have serious restrictions on their internet access. Social sites can be blocked entirely and JavaScript can be disabled on their four- to five-year-old version of Internet Explorer.
This means your flashy new site may not even be visible to some of the public bodies you’re either working with or trying to impress. Even the simplest site created for a client may not display correctly or, worse, actually work when viewed from within some of the commercial organisations that are there specifically to help new businesses.
The wider population
In addition, many areas of the world are still using old, low-powered, second-hand computers, have slow internet access and are dealing with even older, slower software. And this is small potatoes when compared to the problems JavaScript can introduce into a site for someone with disabilities.
With increasing numbers of public services now being accessed primarily through the internet, the number of disabled people online is growing incredibly quickly. Yet many agencies don’t recognise the problems these users can face when they come across the clever JavaScript in a website.
Text-to-speech interpreters and magnification tools can operate incorrectly or, in some cases, crash an entire page when encountering some hastily inserted JavaScript. Or, if the site is wholly reliant on JavaScript, then it doesn’t work at all.
These are issues that far too few developers consider when planning a new project or creating something specific for a client. The number of sites with no ‘Plan B’ for the situation where the user has JavaScript switched off is quite incredible (have a play with your favourite JavaScript sites and see).
An over-reliance on JavaScript is not only likely to lose you (or your client) customers, but in some cases you’re losing out on profile and page rank, since search engine spiders don’t routinely index content generated by JavaScript. Worst of all, you’re actively ignoring a whole audience of people who may be entirely reliant upon your website for access to information or services, thanks to some poorly placed JavaScript.
JavaScript is a clever piece of technology. It’s useful in a number of areas, enabling websites to offer more flexibility and interactivity than HTML alone. However, it has to be considered in the context of the audience. Who’s going to be using this? Are they going to have JavaScript? If they don’t, if they have an older browser, if it has JavaScript switched off, or if they’re using additional technology to read or access the site, will it work?
Some simple questions can mean the difference between having a site that provides a few with an all-singing, all-dancing experience and one that works for everyone. Sometimes a bit less can mean an awful lot more. To people who really need it.
This article originally appeared in issue 217 of .net magazine - the world's best-selling magazine for web designers and developers.




15 comments
Comment: 1
Comment: 2
A simple multistage form served over AJAX is OK but a complex set of interactions offloaded to the browser doubles the work if this has to also be built server side as well. This also requires skillsets front and backend. This is a hard sell to clients to increase the cost of build by 10-20% for 1% extra market share. As you say if it's important to the clients audience then the market share will be higher.
Comment: 3
Personally, despite the opinions of my peers, I always build all of my sites to function without client-side scripting and then utilise progressive enhancement to offer a richer experience for those who do not have locked-down or antiquated software.
The main reason for this is that my first job as a web editor was within a company whose IT department locked down absolutely everything and would not migrate from IE6, such that my browsing experience was severely hampered. It is always in the back of my mind whenever I work on a project.
It still amazes me how many people forget that Javascript is not entirely ubiquitous, especially in regard to using Javascript for effects which can easily be achieved using pure CSS; I cite content-heavy drop-down menus within many large websites as an example. If Javascript is turned off, a large section of the site is difficult or nigh on impossible to access as the navigation does not function. The same effect could easily be achieved through the use of the :hover pseudo-class as opposed to client-side scripting.
Comment: 4
Most developers do not take this approach. I find it in competitors websites on a daily basis. You have no idea how badly crippled some websites become with JS turned off.
Browsers are becoming advanced quickly, but sadly their are still too many older browsers still in use. With all of the JS and CSS differences it virtually makes fast development impossible. At some point you just have to discontinue support for older browsers.
I think in many ways I wish I never started using JS.
Comment: 5
Comment: 6
"Enable Javascript to get the most out of our site"
That's not ironic at all! :o)
Comment: 7
The first to code your Javascript is to develop it using OOP.
If you make this you can use different design patterns that allows you to divide better your code.
After this you must make an analysis of what is really, really important and necessary to be loaded with the page, and what can be loaded in asynchronous mode or being deferred to the actions of the user.
In my company following this steps we reduce the time from 6 secons of load to less than 2 seconds.
We have a modular environment created using the Hydra.js(http://tcorral.github.com/Hydra.js/) that allows to divide the code by funcionality.
Test it, and send your feedback.
Comment: 8
JavaScript can enhance disability issues with better tabbing and arrow navigation. It can also make use of WAI roles.
There's a lot of talk in the post and in the comments about old browsers. Old browsers had JavaScript. That's a compatibility issue, and has nothing to do with the age of a browser. If your target audience is a government agency with JavaScript turned off, then you will know that upfront and obviously won't be building an Ajax-heavy app.
So you're pretty much left with people who turn off JavaScript because they don't like all that "Ajax-y" stuff and it helps block ads. That will be less than 1% of your audience. Your resources would probably be better spent targeting IE3 and Firefox 1 than these people.
Comment: 9
Comment: 10
Comment: 11
Comment: 12
Comment: 13
a) a clear and minimal layout
b) solid content
c) as little as possible advertising
d) display completely and correct with NoScript turned on
There are quite a few such sites online I find but immediately when I come across such a site I feel so released that some people actually understand that "less is more". Honestly if you think you have a full on flash and js loaded site to impress your viewers you are actually turning them away. Most first time visitors of a site will leave if the site does not load within 1-3 seconds. Do not forget that visitors come to your site searching for content and not for your web design magic skills.
Side note about w3schools: Check out http://w3fools.com/ Taking stats from w3s is OK I guess.
Comment: 14
Comment: 15
No1partypills