Making JavaScript Applications Degrade Gracefully
(Page 1 of 4 )
JavaScript is widely used for applications throughout the web. That's fine, but what happens when someone who has disabled JavaScript on their browser tries to use one of those applications? Nothing -- literally nothing. Fortunately, there is a way to make JavaScript degrade gracefully and improve your visitors' experiences. Keep reading to find out more. This article is the first in a series.
Introduction
As the enthusiast web developer that you certainly are, quite possibly you'll agree with me that the present and future of JavaScript-driven applications looks really brilliant and promising. Considering that the number of robust third-party JavaScript libraries available on the web these days continues growing, and that the range of web sites that rely upon this popular client-side scripting language is on the rise as well, it must be admitted that the health of JavaScript seems to be better than ever.
However, this impressive growth in the development of JavaScript applications has also introduced an undesirable effect that many experienced users can see clearly when surfing the web. More and more web sites are replacing sections of their structural markup and their server-side web applications with JavaScript routines to provide potential users with a richer and more interactive experience.
So now it's common to visit web sites that implement different kinds of fancy drop-down menus as part of their main navigational bars, or dynamically display their database contents via thorough AJAX-based applications. Indeed, this scenario sounds pretty neat, right? Well, not so fast. While JavaScript can be really handy for empowering the existing functionality of certain web-based applications, it's fair to say here that relying entirely on it to make these applications work correctly is an erroneous approach that should be avoided.
As you can see, this opinion has much of common sense and little or nothing of proven software design principles. However, let me describe quickly a hypothetical situation to show you the magnitude of the problem: say you're using AJAX on your web site to pull out a product catalog from a database table and show the items to visitors. What happens if a user has disabled JavaScript on his or her browser? Of course, your nice catalog won't be displayed at all, which certainly has the opposite effect of what you were trying to achieve, right?
This simple example leads me straight to the subject of this series: as you'll probably know, JavaScript should be used to extend the behavior of certain sections of a given web site, but never to display relevant content. Logically, this definition implies that it's possible to include, on a web site, JavaScript applications that eventually may degrade gracefully under specific client-side conditions, without having to sacrifice critical functionality.
Thus, taking into account this fundamental concept of web development, in this series of articles I'm going to show you some concrete examples where JavaScript can be used to enrich the existing behavior of a particular web site, without breaking the site's functionality if scripting has been disabled by a user.
Having introduced you to the subject of this series, let's learn together how to make a specific JavaScript application degrade gracefully. Let's get going!
Next: Working with combo boxes to extend a site's behavior with JavaScript >>
More JavaScript Articles
More By Alejandro Gervasio