Feed Sign in with OpenID OpenID

Simon Willison’s Weblog

Is It OK to Require JavaScript? Not if you can avoid doing so. Unobtrusive JavaScript really isn’t hard if you design it in from the start, and since stackoverflow is a community forum / questions and answers site I have trouble imagining a feature that can’t be made to work without JavaScript.

8 comments

  1. I'm getting there with graceful websites that work with or without Javascript, but I'm stuck on one thing: allowing text links to trigger POST requests.

    The HTTP purist in me says that an action (e.g. delete) should be performed via a POST (the absolute purist says use DELETE...)

    The graceful degradation part of me wants a text link to make a POST request without Javascript, but I can't see how to do that.

    If you have any thoughts (sorry if I'm hijacking your post Simon) I have it explained in more detail here: http://www.yetanotherblog.com/2008/05/28/http-good -practise/

    Sven Latham - 10th June 2008 09:34 - #

  2. I don't get this question. At least, I don't get why people feel the need to ask it.

    If you think through a process properly before you get started, there are few (if any) situations you can't deal with using standard 'internet' transfer.

    It doesn't make sense to do it any other way. Why actively rule out anyone? If I was building a... building, I wouldn't choose to not build a ramp just because I figured most people visiting could walk up steps unassisted ok. (That's not to say there aren't other reasons not to build said ramp, of course.)

    Andrew - 10th June 2008 10:58 - #

  3. Simon, I agree, but I'd really like to hear you go into more detail on the point. I've encountered other web developers who take the position that most users have JavaScript nowadays, WAP browsers are going nowhere but iPhones and Opera Mini allow for JS, etc.

    And while I do still agree with your position, it got me thinking - why is it that we ensure web pages can be used without JavaScript? Is there ever a time when JavaScript should become just another part of the Web, like images or CSS? (And yes, I do ensure pages degrade gracefully without CSS, so maybe that's a bad example. :)

    Joey Tyson - 10th June 2008 13:50 - #

  4. I would agree with you, that with proper planning there is no real reason to build it with the JavaScript requirement. Even complex applications could be built with progressive enhancement in mind, their user experience would just be shaped differently.

    Could some of this be attributed to laziness? Lack of education of the possibilities?

    RE: POST links
    This simply is a constraint you have to deal with in HTTP. Without the help of JavaScript, you can't simulate the POST request (that I know of). So, maybe plan accordingly knowing this can't happen? Make the text link a form with a post request (checkbox or radio button), and if they have JS enabled override and replace with a link and generated POST request. This is a simplified example - but think about the possibilities and what you are trying to achieve.

    Nate Klaiber - 10th June 2008 15:56 - #

  5. Sven, I'd argue that links submitting POST requests are inherently bad behavior. Just like developers should know that GET is idempotent, users should have some sense that links go places and buttons do things.

    Braden Anderson - 10th June 2008 16:52 - #

  6. "why is it that we ensure web pages can be used without JavaScript?"

    I remember reading somewhere not too long ago that there are some fairly large companies that block JS in their draconian provision of web to their employees.

    And if it's a non-savvy employee, they won't even know it, and wouldn't know what to do -- or be able to do anything -- if they did.

    Elaine Nelson - 11th June 2008 00:04 - #

  7. "Why actively rule out anyone?"

    The last treatment of this topic that I read incorporated arguments from the "shiny brigade" who tried to manoeuvre the argument round to "all mainstream browsers support JavaScript anyway", but there are many reasons why people might not want to run JavaScript - some being mentioned here, I see.

    I know that some people are infatuated with AJAX, but any requirement for JavaScript is arguably laziness combined with a desire (or a compulsion) to replicate the desktop experience (and some of the more tiresome programming practices associated with it) in the browser.

    Paul Boddie - 11th June 2008 12:46 - #

  8. If you're writing an intranet webapp where everyone is using a standard browser and will have JS enabled, then you can make a case for the expediency of forgoing progressive enhancement on the basis that YAGNI. Simple pragmatism -- why make work for yourself?

    dmc - 11th June 2008 18:06 - #

Sign in with OpenID

Auto-HTML: Line breaks are preserved; URLs will be converted in to links.

Manual XHTML: Enter your own, valid XHTML. Allowed tags are a, p, blockquote, ul, ol, li, dl, dt, dd, em, strong, dfn, code, q, samp, kbd, var, cite, abbr, acronym, sub, sup, br, pre

A django site