Vesta Digital Blog

4 Reasons to Limit Your Use of JavaScript

Posted on: February 11, 2010

JavaScriptThis headline is not a typo. Read on and you will find out why. JavaScript is used almost everywhere to accomplish a wide variety of features like hover menus, rollovers, animation and form validation. In fact, JavaScript is used so frequently web developers often take it for granted, without realizing that not all browsers support it. You heard right, not all browsers support JavaScript. In fact, many web surfers actually disable JavaScript and if you’re wondering why – take a look at the list below.

1. Pop-up Windows.

Web developers often create annoying pop-up windows which are more irritating than useful. The best way to get rid of them is to disable JavaScript.

2. Security.

One of the most important reasons is security, and it is a well known fact that JavaScript can be easily exploited. (This is especially true for users browsing with Internet Explorer.) Additionally, many redirects are accomplished via JavaScript. By disabling JavaScript, you always know exactly where you are going and are less likely to be forwarded to an alternate website.

3. Animations and Sounds.

Have you ever been at work and navigated to a website which started playing loud music or sounds? A lot of this is accomplished by JavaScript. Additionally, by disabling JavaScript, you can also get rid of annoying animation which clutter the screen or distract you from the information you are trying to see.

4. Annoying Restrictions.

Sometimes websites limit the actions that can be taken by visitors. For example, you have probably seen the websites which stop users from viewing the source code, saving images, or highlighting text.
Alternatives to JavaScript
Clearly, there are many good reasons internet users would opt to disable JavaScript in their browsers. And while estimates aren’t too accurate, somewhere between 5 and 7 percent of internet users disable JavaScript. That means that at least 1 in every 20 visitors might not see your website as you intended. So it is important to ensure that your website works properly with or without JavaScript.

Fortunately, other internet technologies can accomplish most of what you would probably use JavaScript to do:

Hover Menus

Believe it or not, you don’t need JavaScript to create a hover menu! Sometimes, however, you might want to create a cool effect which is only possible with JavaScript. In this case, feel free to create the JavaScript menu, but pay special attention to how the menu behaves without JavaScript. Be sure that it can still be used to navigate your website.

Image Rollovers

This can be accomplished by CSS by using the ‘hover’ state to shift the position of an element or show a new element. Either way, rollovers are rarely crucial to the usability of a web page.

Redirection and Form Validation

Fortunately, there are alternatives for these as well. When you use JavaScript, it is always processed on the client-side, which is why users are able to modify the behavior of the web page when they turn it off. Instead, you can opt to do all of your processing on the server-side, by using a programming language. For example, our contact forms use server-side validation to ensure that a valid email address has been entered, even though this could be accomplished with JavaScript. By opting for server-side processing, your users will always be subject to certain restrictions. Similarly, you can use a programming language to redirect users to other web pages.

Animation and Pop-ups

For animation, there are two alternatives: (1) create an animated gif image, or (2) use flash. Both of these methods have their drawbacks. With the animated gif image, you are limited to creating an image with a reasonable filesize. (The longer the animation or larger the image, the larger the file size.) And finally, if you opt to use flash, you will encounter some of the same problems you encountered with JavaScript: Not All Visitors Enable Flash. And like the animated gif, you are likely to have some file size issues as well. As for pop-ups, we are at a loss. Instead, you will have to bait your users to click on a link which would open in an external window or tab (Let us know if you’ve found suitable alternatives.)

So if you are building a website, by all means use JavaScript. But it should only be used on elements that are not crucial to the use of your website. And if, for some reason, JavaScript is essential to the use of an element on your page, consider supplying some alternative text explaining what the element is and that users need to turn on JavaScript to take advantage of it.

Advertisements

1 Response to "4 Reasons to Limit Your Use of JavaScript"

Javacsript and I tend to be mortal enemies. Although I’m a little hypocritical since I let it go to work on my blog….

When I get the chance I have a default fall-back for people who have javascript turned off, or if it’s unavailable.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: