Do You Really Need JavaScript?

vlence

Victor Basumatary

Posted on April 21, 2020

Do You Really Need JavaScript?

There's a new JavaScript library/framework released everyday and your node_modules/ directory is only becoming more denser than a black hole, but do you really need that JavaScript running in your website? Do you need JavaScript at all?

The examples that I am going to show you in this article were valid as of 21 April 2020 (Indian Standard Time).

1. swiggy.com and google.com

Swiggy is a food delivery company and application here in India. Here's how the application works with JavaScript enabled.

Selecting a delivery location in swiggy.com.

Selecting a nearby restaurant in swiggy.com.

There's a giant textbox where you enter your location. You are then presented with a list of locations that Swiggy delivers to near you. After selecting an appropriate location you are redirected to a page with a list of restaurants that service the selected location.

Here's what happens when JavaScript is disabled.

swiggy.com cannot suggest delivery locations with JavaScript disabled.

You still get the same page as we did with JavaScript enabled but this time Swiggy cannot provide you with a list of suggested delivery locations. Furthermore, you cannot progress further in the app. I'm left hungry if I have JavaScript disabled.

Let's now take a look at how we use Google with JavaScript enabled.

Searching for the term "software engineering" on google.com

Search results of the term "software engineering" on google.com

We've all used Google right? Now let's see how Google behaves with JavaScript disabled.

Searching for the term "software engineering" on google.com

Search results of the term "software engineering" on google.com

We can still get search results with JavaScript disabled. You may have noticed that Google could not provide you with autocomplete suggestions.

Observations

Google used JavaScript to enhance the experience of searching, with autocomplete suggestions and a better UI, among other things. The core feature of Google - searching - does not depend on whether we have JavaScript enabled or not.

Swiggy relies on JavaScript for its core feature - searching for restaurants around you - and so fails to work when JavaScript is disabled. Does Swiggy really need JavaScript to provide that feature to you? In my opinion, no. On the home page you need to enter a delivery location. This delivery location can be sent to the backend application which can use this along with other information like the IP address to find a list of areas that the customer might be in. The application selects the best choice and presents restaurants around that area along with the other possible locations in case the customer is elsewhere and the application made a mistake.

2. angular.io and reactjs.org

Both Angular and React are used to build Single Page Applications and if you're like me, you keep their documentation open at all times when using them. Here's Angular's and React's websites with JavaScript enabled.

angular.io with JavaScript enabled.

reactjs.org with JavaScript enabled.

And here they are with JavaScript disabled.

angular.io with JavaScript disabled.

reactjs.org with JavaScript disabled.

Angular's website only says "This website requires JavaScript" when JavaScript is disabled.

Observations.

Do you really need JavaScript to read some documentation? No. angular.io is completely unusable when JavaScript is disabled.

reactjs.org will do a full page reload when you have JavaScript disabled, otherwise it won't. I'm pretty sure there are other features missing in the website with JavaScript disabled but this is the most glaring one to me. Again, JavaScript was used to only enhance the experience of the user.

Final Words

You don't need JavaScript, for a majority of the applications out there, to deliver the core feature(s) of your application/website. Websites should be built with the assumption that JavaScript is unavailable. If JavaScript is used, it should be used to enhance the user's experience. The experience should not depend on JavaScript being available.

Why Should I Care

Your user may not be able to run JavaScript for a variety of reasons:

  • The user agent may fail to download the JavaScript after downloading the HTML
  • The user may have disabled JavaScript
  • The user agent may not support JavaScript
  • The user agent may not support the version of JavaScript you used
  • And a host of other things
💖 💪 🙅 🚩
vlence
Victor Basumatary

Posted on April 21, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related