Do You Really Need JavaScript?
Tags: webdev, javascript, html, css
Published: 2020-04-21 13:46:54

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.](https://dev-to-uploads.s3.amazonaws.com/i/is55cmulurxai7t0y69j.png)

![Selecting a nearby restaurant in swiggy.com.](https://dev-to-uploads.s3.amazonaws.com/i/vng0c9c4k39g5vc3i1k3.png)

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.](https://dev-to-uploads.s3.amazonaws.com/i/4132fgpk0163lbd3eg3i.png)

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](https://dev-to-uploads.s3.amazonaws.com/i/r06zopd8v6imgd39mwdq.png)

![Search results of the term "software engineering" on google.com](https://dev-to-uploads.s3.amazonaws.com/i/k5729ywb4m3m1zlz3bka.png)

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](https://dev-to-uploads.s3.amazonaws.com/i/md8c7fxiwki2kbj31e9r.png)

![Search results of the term "software engineering" on google.com](https://dev-to-uploads.s3.amazonaws.com/i/lb9p3v72uz1nntxtxy24.png)

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.](https://dev-to-uploads.s3.amazonaws.com/i/38vuhhzqc9kh34k0q2kh.png)

![reactjs.org with JavaScript enabled.](https://dev-to-uploads.s3.amazonaws.com/i/8e8jsbgpet90zqk425hd.png)

And here they are with JavaScript disabled.

![angular.io with JavaScript disabled.](https://dev-to-uploads.s3.amazonaws.com/i/900lgqfie10wusbx7yrn.png)

![reactjs.org with JavaScript disabled.](https://dev-to-uploads.s3.amazonaws.com/i/1yd68td8ar22ujomdk80.png)

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