Don’t be degrading

The other day week Shelley was extolling the virtues of degrading, having your JavaScript tricked-out page fall back to something still usable when JavaScript isn’t enabled. I meant to poke at that with a different stick at the time, but it slipped away until Cameron Adams claimed that you should sometimes just say “screw you, JavaScript’s required” and reminded me.

There are probably cases where Cameron’s right, and there’s just no way you can do what you want to do without JavaScript (though I found the 37signals explanation he linked to, that JavaScript is required for the experience we want to provide rather unsatisfying), and maybe even cases where Shelley’s approach, write your pretty shiny toy, but then remember to see how it looks without JavaScript (and don’t forget without CSS, with and without JavaScript), works well, but mostly neither one suits me.

If instead you do things the unobtrusive JavaScript way, first writing the basic HTML to do what you want, whether it’s an ordinary comment form or a list of checkboxes, and then get out of the HTML completely, doing all your enhancement in separate stylesheets and JavaScript files, at most dipping back into your HTML to add an id to an element when you need an easy way to grab it, then you don’t have to worry about how you’ll degrade, because you already started out working as well as you can with as little as possible. It’s not as much fun as jumping right into the sexy stuff, but you won’t leave nonfunctional bits in your HTML for people without JavaScript if you only put them in with JavaScript, and you won’t deny someone the ability to note what they need to do on a borrowed computer that they can’t alter if you start out with the basic functions, and only after they work start making them snazzy.

6 Comments

Comment by Kafkaesquí #
2005-04-11 20:21:59

I recently finished up a project floating in javascript, which really offered no good way to back out of things without flipping the backwards visitor a client-side bird. It does so without malice, however. You can be rude and not mean if you work at it.

That’s not to say some of the functionality could not have been sans-js, but it would lack what I consider the alpha and beta features of the tool, and require a near complete rewrite of the pre-existing component my work was built around. So my choices were to focus on a handy little virtual mechanism that does what I planned, all wrapped up and on public display in just a few days, or find myself still working on what may be needed by an individual or two each week. So yeah, sometimes I choose the finger. But in a nice way.

By the way, it was interesting having to babysit Netscape’s bastard child once more. For the most part I like to ignore it and stick to that other side of scripting (old habits, etc). The time spent with it brought back something I nearly forgot: it’s never enjoyed my company.

 
Comment by Lachlan Hunt #
2005-04-12 08:31:28

Well said! It’s good to see some people understand how important graceful degredation is; and how easy it is to achieve by starting from the ground up with accessible HTML and then progressively adding bells and whistles to make it snazzy.

 
Comment by cedric #
2005-04-12 09:38:16

I guess you have to keep in mind who your audience is. If you build a tool for web designers / developers, you can reasonably ask for javascript to be enabled.

If you target a broader public, then yes.. make it degradable.

Comment by Phil Ringnalda #
2005-04-12 09:46:05