Skip Navigation

Use More JavaScript

JavaScript is possibly the single most argued-over technology on the web. It is very powerful, allowing client-side scripting that (when it works) can bring a page to life, adding functionality and making a user's experience much more enjoyable. It is also, sadly, the technology used to spawn popup windows on the unfortunate folk using poor browsers, and the technology used by teenage girls to make a string of hearts follow the mouse around the screen.

It is because it is so powerful, and so often misused, that there is so much argument about it. One the one hand, there are thousands of legitimate uses for JavaScript, from client-side form validation (not safe by itself, but can save a user having to load a new page to se a field they missed on a form) to time and date-related functions. On the other hand, people can grab a list of the last 10 sites you visited, your email address, and more, and without you even seeing it.

For those reasons, and many others, there are a great many people who do not use JavaScript. Many decent browsers allow you to turn JavaScript off easily and quickly, and many browsers simply do not have JavaScript support. Search engine spiders, too, cannot make use of JavaScript. Which means you have to be very careful when using it.

The main mistake made with the use of JavaScript can be seen on all too many sites. Many web designers and developers assume that, because so many people use Internet Explorer, that everyone must have JavaScript support, when the truth is that only around 80% - 85% of users actually have JavaScript supported or turned on.

Many would ignore this fact and plough on, making a site unusable for those without JavaScript, instantly preventing a huge proportion of potential customers from actually using their site. Even ignoring those users without JavaScript support, the number of users who will simply never find your site because you are not listed in any search engine results is astronomical. As soon as you make JavaScript an integral part of your site, you are losing sales, and then you might as well just pack up your dotcom and take up a new career.

It is usually better to think of JavaScript as an add-on. If you can save the user some time, or make their browsing experience easier or more enjoyable with the use of JavaScript, then by all means do so. If you can save them having to refresh a page when they submit a form, or give them more navigation options without cluttering up the screen, by all means, go for it. If you must use JavaScript for something important, always provide alternative content through the "<noscript>" tag. And always test your site in a browser with the JavaScript turned off (see bottom of page).

There is no reason JavaScript should be so widely hated. It can be (and often is) misused, but that doesn't mean it cannot be used well on occasion. Used correctly, it can make a user's experience on your site much more enjoyable and productive, and that is what you should be aiming to do if you ever want them to return.

How to turn JavaScript off in browsers

Opera

  1. Press F-12 and uncheck "Enable JavaScript".

Firefox

  1. Click on Tools > Options > Web Features and uncheck "Enable JavaScript".

Internet Explorer

  1. Click on Tools > Internet Options > Security > Custom Level.
  2. Scroll down to the "Scripting", and underneath "Active Scripting", select "Disable".

7 comments

Pete
United Kingdom #1: April 30, 2005
Where did you get 80-85% of people have js enabled from? I've been trying to find stats on this but having been finding much as yet. Also interesting article, guess somebody out there now knows I like girls from a wide age range and backgrounds!
Paul Walker
Australia #2: May 15, 2007
I'm also wondering where that statistic came from - from what I've seen (on my site) its more like 98%, the w3cschools stat is 94% and rising http://www.w3schools.com/browsers/browsers_stats.asp
i think more people need to activate it, because of the web 2.0 standards. Since a few months on our sites we recognize that trend too. What do you think is the reason?
Benjamin Tremblay
United States #4: May 14, 2008
A web browser with JavaScript disabled is a broken web browser.

JavaScript is an inseparable component of the web experience. Debating whether or not to use JavaScript is like debating whether or not to use CSS. It's not possible to make a good web site without JavaScript, and that's the way it should be. Web sites are applications, and they must respond to user input like applications, not like so many request/response page loads. This is simply a matter of fact in 2008.
Benjamin: You are deeply deeply wrong.

What about text browsers? What about screen readers? What about search engin spiders? What about the founding principles of the web - that it be accessible to all on any device?

There are people who turn JavaScript off because they're sick of tacky effects (snow falling, something following the mouse, etc). Or because so many people write such bad JavaScript, or use so much of it, that they render a computer virtually useless while their page is active on it.

And as for your comment that it's not possible to create a decent web site without JavaScript - there are millions of examples of sites that use JavaScript well, where a lack of JavaScript doesn't render the site useless.

Progressive enhancement and graceful degradation are two principles that allow you to use JavaScript responsibly.
Pete and Paul:

I've gotten the impression that you are looking for absolute statistics, which is utterly impossible. User agent technology support statistics vary from site to site.

As Dave mentioned, user agent capabilities vary as well (although some people willingly turn off JavaScript, some don't even have a choice). As such, you would not expect many visually impaired people to be learning web design or programming, so that (among many other factors that consider the site's target audience) contributes to the smaller number of visitors with JavaScript disabled.

Dave pretty much hit the nail on the head in reply to Benjamin. You should start building your page with exclusively semantic HTML, which makes the page 100% accessible to modern user agents, then add CSS, but without changing the HTML as much to make it difficult to access for user agents that don't support CSS (don't use tables for layout). You should add JavaScript using the same principle as when adding CSS, i.e. not breaking accessibility.

JavaScript can be a great addition to a web site for those that have it enabled, but don't hinder the accessibility of those who haven't.
jason
United Kingdom #7: July 13, 2008
Hi everyone, i have only just learned how to write (x)html and css, and im currently half way through building my own site, the one problem i have is that i cannot write javascript and i dont know where to start learning it, i dont wan to use very much of it at all, ive just been told that if i want to add a better graphical/visual look to my site then i have to use j/script, but i dont know how to write it or know where i can learn it, is the advice ive been given true? wil my site be overlooked by so many people coz of not using script?
Im confused do i learn it or not? if yes how do i learn it?
Thanks alot for reading this
j.

Post Your Comment

· Comments with keywords instead of a name have their URLs removed.
· Your email address will not be displayed or shared.

Live Comment Preview

 United States #8: 1 minute ago