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

No, if you build a toy for web designers / developers, you can reasonably insist that JavaScript be enabled. If I’m borrowing a computer which has JavaScript disabled, and I’m not allowed to change that, and as a result I can’t use your thing, then your thing is no longer a tool, it’s a toy.

 
 
Comment by dave #
2005-04-14 09:33:25

The word NO and DON’T are key here. 37 signals et al are very wrong with their excuses for doing things properly.

It is all about separation, content from presentation, AND content and presentation from behaviour… function (basic) is a constant and cannot be removed. Focus on any device or group of devices is not an option in my opinion as the range is widening, not narrowing as mobile access explodes.

I wanted to respond when that post went up on svn but was too angry, and felt my presence (ranting) would not be welcomed amongst the other (imho) uninformed commenters. Thanks for bringing it up here, as it is a very important factor to consider.

Just when we got this far with javascript not being misunderstood, attitudes like that run the risk of relegating the language back to it’s previous misguided reputation.

 
Comment by Norman Walsh #
2005-04-22 08:49:54

+1. +10, maybe :-)

 
Name (required)
E-mail (required - never shown publicly)
URI
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <del datetime="" cite=""> <dd> <dl> <dt> <em> <i> <ins datetime="" cite=""> <kbd> <li> <ol> <p> <pre> <q cite=""> <samp> <strong> <sub> <sup> <ul> in your comment.