Most sites nowadays use JavaScript, and if you want to offer a fluid user experience it is usually one of the best choices.

However I've noticed that a disturbing amount of websites become practically useless if you disable JavaScript, this is (in my opinion) terrible practice, and terrible design.

Why does this matter?
Most people who will access a webpage will have JavaScript enabled, it is pretty standard these days, However that doesn't mean everyone has JavaScript enabled and you shouldn't overlook these users who are unable to run scripts or just don't want to.

Some other reasons as to why this matters:

  • The website is a lot more dependent on the client:
    Everyone has different Operating systems, different browsers and people update these things at different rates. This increases the chance of failure substantially and this can cause issues if a website relies on a newer JavaScript feature and the user's browser doesn't support it, the website is now useless to the user as they have no way of using your website without changing their browser.

  • The website isn't "failsafe":
    If the website isn't designed to be able to work without JavaScript and if your JavaScript breaks it becomes useless to the user.

  • It's more difficult to maintain:
    This is very dependent on how much you use JavaScipt, but the less a website relies on JavaScript the likely you will have to flip-floping between your serverside script and your JavaScript when you want to change something.

  • It can be resource intensive:
    Depending on what is being done with JavaScript it can be very resource intensive for some users, by putting most of the work into a serverside script the server does most of the heavy lifting, which can cut down on how much resources the user has to use.

Does this always matter?
Short answer: No.

Long answer: There are some cases where it may be difficult, impossible or inefficient to make the website function without JavaScript, a few examples are:
  • A web chat.
  • Content loaded with cURL or equivelant:
    Content loaded over HTTP such as with cURL tends to increase page loading times by a substantial amount, ideally you should try and make it so you request data over HTTP as little as possible, in some cases however this content could be loaded in a frame, rather than with JavaScript.
  • A music or video player*

Obviously this list in in no way comprehensive, but it should give you the gist of it.

What should be done?
I personally develop with my first aim to make the website functional without any JavaScript, once I have a solid website I begin to add various JavaScript and AJAX features to make the user experience even cleaner for users with JavaScript enabled.

A couple things to consider:

  • use the <noscript> tag, this tag allows you to specify content that is only displayed when the user does not have JavaScript enabled.
    <noscript>Please enable JavaScript to get full functionality.</noscript>
  • If an element is hidden and then shown with JavaScript add a CSS rule in a stylesheet in a <noscript> tag to display it.
  • If you are using JavaScript to display responsive content, have a look at CSS media queries.
  • Check in your serverside script whether or not the request is AJAX or not and output accordingly, an example of this in PHP is:
    if($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
        //AJAX request
    } else {
        //Normal request
  • Don't use JavaScript for the sake of using JavaScript. Basically if something can be done without JavaScript, that is often the better way to do it.

TL;DR JavaScript should enhance the experience, it should not be the experience.

Progressive enchantment is a good strategy.

If you have any input or criticism, feel free to comment below.

*Depends on how complicated it is and what support you want, you can make some pretty nifty music and video players with nothing but HTML5
Last edited 8:22 PM (UTC) on 29/10/2018 by Bacon.
Posted by: Bacon
[spoil] [hr]
[Close Tags]