JavaScript is used all over the internet to accomplish a wide variety of features such as hover menus, rollovers, animation, and form validation. In fact, JavaScript is used so frequently that web developers often take it for granted, without realizing that not all browsers support it. Yes, that’s right, not all browsers support JavaScript. And if that isn’t bad enough, many web surfers actually disable JavaScript.
If you’re wondering why anyone would disable JavaScript, take a look at our list below.
Clearly, there are many good reasons an 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:
Believe it or not, you don’t need JavaScript to create a hover menu! Stu Nicholls, an impressive CSS/XHTML developer at CSSPlay.co.uk, shows the possibilities of CSS with at least 100 different kinds of CSS menu examples. (Feel free to peruse the rest of the CSS Play website. In addition to menus, there is a wide collection of other amazing CSS accomplishments.)
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.
Believe it or not, this too 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.
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, such as PHP or ASP, to redirect users to other web pages.
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 filesize.) 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 filesize issues as well.
As for pop-ups, we’re 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, you are free to use JavaScript. But its 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.
Tags: browsers, cross-browser compatibility, JavaScriptTrackback URL for this entry:
http://www.velvetblues.com/web-development-blog/reason-to-limit-use-of-javascript/trackback/
Contact us today for a quote. Click here to submit details regarding your project.
If you are making a general inquiry, send an email to info@velvetblues.com
I hardly know where to begin. So many presumptions are offered as facts, it boggles the mind.
Let’s talk browser security. Internet users know there’s a difference between a popular browser and a secure one. Internet Explorer is popular, but FireFox is secure (as is Opera and Safari and Chrome). Security is not a javascript issue, it’s a browser issue. More specifically, it’s an Active-X issue! Yes, that casts a long shadow over IE.
When folks decry javascript security issues, they’re not castigating all browsers in general, they’re bemoaning one in particular; Redmond’s. They’re complaining of the fact that IE is riddled with insecurities, because it is so tightly integrated into the OS. (What other browser wrongly depends on the CLSID of the tag to invoke Flash content, for example.)
This will be a painfully obvious conclusion, but I’ll draw it nonetheless: the less IE is used, the less impact its lack of security will have on the Internet population. One could argue there are reasons to favor IE, but security isn’t one of them. The browser enjoys popularity by virtue of the fact it is ubiquitous.
The article cleverly ignores foundational reasons developers implement javascript. What about frameworks? It’s been a almost year since the article was authored, and javascript APIs have been around alot longer than that. JQuery, Protocol, YUI, MooTools… and the list goes on.
These frameworks permit designers to design websites where the bulk of processing occurs in the client (not the server), where data validation is done in realtime, and where presentation is attractive and quick.
And what about the widespread use of Content Management System (CMS) websites? Drupal, arguably one of the most popular, secure and feature-laden CMS tools available, uses javascript. Back in 2006, the JQuery API was incorporated into the Drupal core. Where were the harbingers of doom when Drupal made that decision?
Finally, what further point could be made than the absurdity of eliminating AJAX in current websites? No javascript, no AJAX. The DHTML/AJAX paradigm is what enabled us all to begin shouting, “web 2.0, web 2.0!”
In conclusion, there are no compelling reasons to disable javascript. It is as endemic to a page as CSS and the markup itself.
There are browsers that fail at security, and thankfully there are excellent alternatives to them. If it’s a matter of trust — not knowing whether a website is safe — than all the neutering of javascript won’t fix that.
But changing your browser might.