Results 1 to 7 of 7

Thread: Best JavaScript Fallback Practices

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Best JavaScript Fallback Practices

    This is mostly directed toward SambaNeko or penagate, I must admit, but anyone is free to share their thoughts.

    What would you say are the best practices for providing a JavaScript fallback? Should I utilize the <noscript> tag, or is there a better way? If I do use the <noscript> tag, should the JavaScript-y content just be placed in an element which is not displayed by default, but has JavaScript that makes it visible?

    The website I'm working on is very modern and aimed at modern users (not supporting IE7 or below), but because of the potential for projects with educational institutions, I don't want the website to break just because they have JavaScript disabled.

    In addition to this, how might you provide the functionality of a carousel without JavaScript: would you outright hide it from non-JavaScript users? Or would you do the extra work to build the functionality in with PHP?

    Or, might you simply provide a very basic/static version of your website for non-JavaScript users?
    Like Archer? Check out some Sterling Archer quotes.

  2. #2
    Frenzied Member
    Join Date
    Apr 2009
    Location
    CA, USA
    Posts
    1,516

    Re: Best JavaScript Fallback Practices

    If they don't have Javascript, I send them to the internet archive's copy of my site from 1995. Works great!

    Pretty much your last sentence, which I'll rephrase as a doctrine of progressive enhancement. Every browser (user) gets the best version of the site that it is capable of handling; advanced browsers get the full experience, while older ones are unaware of anything they're missing. In the absence of Javascript, all of your core functionality should still work, it just might not work in the same way, or be as flashy.

    For a carousel, I'd show the non-Javascript user only the first "page" of items. You'd need Javascript to page through the rest of the items (and the paging controls are not present in the basic markup: they get added to the DOM onload with Javascript), but you can accommodate the non-JS users with another page that shows all items in a more plain fashion. Like a "view all" page: this is useful both for your non-Javascript users, and for any Javascript users who just don't like carousels.

  3. #3
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Best JavaScript Fallback Practices

    What I do is make the website work 100&#37; without JavaScript, then add the scripting later. I view JavaScript and Flash as enhancements to a website, not requirements. It does get frustrating effectively creating the same things twice: I like to see this as a benefit as well, because it forces you to properly consider whether the scripting you're doing is necessary. In other words, the benefit to the user experience has to be worth the effort. In many cases it is.

    Look no further than this forum for an example of a site that works well with and without scripting enabled. The pop-up navigation menus and quick reply/quick edit are all enhancements to functionality that is available without scripting.

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Best JavaScript Fallback Practices

    Quote Originally Posted by kows View Post
    Should I utilize the <noscript> tag
    No .

  5. #5
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,531

    Re: Best JavaScript Fallback Practices

    OK, I have a related question... how would you handle a site that auto-updates its content? Case in point - I have a website that interfaces with a radio (internet streaming, non-terrestrial) and I want the site to automatically update itself when the song selection changes. Currently, I'm using a timer, which then runs am ajax call to retrieve the new information and updates the appropriate elements on the page. I suppose I could simply have a link somewhere on the page that causes a manual refresh of the page. Expose it when JS is disabled, otherwise, load the JS files and let the scripts run.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Best JavaScript Fallback Practices

    Just make the user refresh the page manually.

    If JS is enabled, then you can either update on a certain interval (like you describe) or you can do an asynchronous request to a script which polls on the server-side until the song data changes, then returns the result. (You need to flush this type of connection every 30 seconds or so as well, to avoid time-outs.)

    Avoid this:
    HTML Code:
    <meta http-equiv="refresh" content="30" />
    Pages which do this are annoying.

  7. #7
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,531

    Re: Best JavaScript Fallback Practices

    Oh, I agree... I wasn't refreshing the entire page... I was simply making an asynch call, getting some xml back, then using that to update specific elements on the screen. when JS is enabled, it works nice... it's when it's disabled that I was looking at... sounds like manual refresh is the way to go.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width