Javascript Optional: Modern React Applications That Work Without JS

Rate this content
Bookmark

Have you ever tried browsing your favorite websites with JS disabled in your browser? It can feel like cutting a lifeline for the internet. Instead of welcoming user-friendly interfaces you’re faced with a blank wall that says “please enable JavaScript“ in the center of it. But it doesn’t have to be that way. 

In this talk, we’ll explore techniques for building modern web applications that can remain functional in a JS-free environment, and provide a full experience when JS is turned on.

This talk has been presented at React Summit US 2023, check out the latest edition of this React Conference.

Watch video on a separate page

FAQ

JavaScript optional applications refer to web applications that can function without the full use of JavaScript. They are designed to provide core functionalities even when JavaScript is disabled, using fallbacks and server-side capabilities to handle data fetching and mutations.

React server components and server actions allow data fetching and mutations to be handled on the server side, rather than relying on client-side JavaScript. This approach is crucial for enabling JavaScript-free experiences by reducing the dependency on JavaScript for interactive behaviors and data management.

JavaScript optional approaches can significantly improve application performance, especially in terms of the Time to Interactive (TTI) metric. By minimizing or eliminating the need for JavaScript, these approaches reduce delays caused by JavaScript parsing and execution, especially on slower networks or devices.

Techniques for building web applications without JavaScript include using HTML and CSS for basic functionality, server-side rendering, graceful degradation for complex features, and leveraging server actions for interactions that typically require JavaScript.

The interest in JavaScript optional applications is growing due to their benefits in performance, especially under conditions of slow internet or low-end devices. Additionally, these applications cater to users who disable JavaScript for privacy or security reasons, ensuring broader accessibility and usability.

Developers face challenges such as ensuring compatibility across different browsers and devices, providing equivalent functionality and user experience without JavaScript, and managing server-side complexities for data handling that JavaScript would typically perform.

Konstantin Lebedev
Konstantin Lebedev
28 min
13 Nov, 2023

Comments

Sign in or register to post your comment.
Video Summary and Transcription
In this Talk, the speaker discusses the concept of building JavaScript optional applications, focusing on the use of tools like React server components, Next.js, remix, React Router, Astro, SolidStarts, and Weld. They explore various aspects such as building eCommerce apps, pagination, adding items to cart without JavaScript, and implementing features like card previews using HTML and CSS. The speaker also highlights the trade-offs and considerations when disabling JavaScript, maintaining cart items, and combining old and new ways of building applications.

1. Building JavaScript Optional Apps

Short description:

In this talk, I will share my findings on building react applications that can work without JavaScript. While highly interactive applications heavily rely on JavaScript, there are many applications that use JavaScript for cosmetic purposes. Tools like React server components, Next.js, remix, React Router, Astro, SolidStarts, and Weld are addressing the challenge of JavaScript-free experiences. Although only a small percentage of users disable JavaScript, the impact on application performance, specifically time to interactive (TTI), is significant.

Great to see so many faces here. And I guess let's jump right in. So the idea for this talk comes from the project that we worked on, which was an experiment to get an answer to the following question. Can we build react applications that could also work without JavaScript? And for lack of a better name, I started calling such applications JavaScript optional. And today I'm going to share with you my findings.

But first, let's talk about web without JavaScript. Some of you may have tried doing this in a browser so you know what I'm about to show you. But for those of you who haven't, I can summarize the experience of browsing web without JavaScript in one slide. Basically, it looks like this. There is a small number of applications that retain some degree of functionality. But in most cases, you will get either an application skeleton that looks like it's loading but it never will, or a simple message asking you to turn the JavaScript back on. And that makes sense, right? Because we know that highly interactive applications come part and parcel with JavaScript. So, without JavaScript, they simply break.

But not all websites are created equal. And while we have a large number of websites that have JavaScript as an intrinsic part for providing their core features, there is an even larger number of applications that use JavaScript to enhance user experience, right? To show more user-friendly input fields, add some micro interactions, things like that. But essentially such JavaScript serves a cosmetic purpose. And so it shouldn't be difficult to imagine that such applications could still work even when JavaScript is off, at least in theory. In practice though, it almost never happens because building applications for JavaScript optional approach requires an intent. But the best we usually do is put a no-script tag with a message and call it a day.

Now, all of that might sound irrelevant but I began to notice that tools and frameworks that we're using are starting to address that. And not only talk about this problem, but also give us tools that facilitate the development of JavaScript optional apps. So starting with latest React and Next.js that uses it. They give us React server components and server actions which allow us to move data fetching and data mutation to the server. Now, this is very important because that ability will become key to unlocking JavaScript-free experiences. Then there is also remix and applications build on top of React Router that use latest data router. They have slightly different abstractions, right? They use loaders and actions but essentially they achieve the same goal, fetching and mutating data on a server. And then even if we look outside of React ecosystem, we'll discover tools like Astro, SolidStarts, Weld, maybe even more that begin to address this problem of JavaScript-free experiences in one way or another. So that brings a question, right? Why is everybody talking about this all of a sudden? And if we look at the statistics of users who actively disable JavaScript in their browser, we're going to discover that the number is rather small, right? It's about 0.2% of all web traffic. But what matters a lot more is how this JavaScript optional approach affects application performance and a metric called TTI in particular, right? TTI, or time to interactive in layman's terms is the amount of time it takes from seeing a button to being able to click on it, because, you know, in React it doesn't happen instantly. We first need to download, parse, and execute the JavaScript bundle.

2. Building JavaScript Optional eCommerce Apps

Short description:

If we build our applications to be usable even before any JavaScript is ready, we effectively reduce the delay to zero. Let's talk about building an eCommerce application using React server components and server actions.

And if we have a large JavaScript bundle and a slow network, then we have a problem, because this delay can extend into multiple seconds, and we see the users leave the website. But if we build our applications in a way that lets them be usable even before any JavaScript is ready, we effectively reduce this delay down to zero, which turns out to be very effective.

And there is a lot more to be said about the reasons for JavaScript optional approach, but in the interest of time, let's talk about a more interesting part and see how we can do it. So, to demonstrate that, we're going to build an eCommerce application. And for code samples, I'm going to use React server components and server actions. But it has to be said that all the techniques that I'm going to show you will work just as well with Remix, and in some cases, the solutions will be even simpler.

QnA

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Building Better Websites with Remix
React Summit Remote Edition 2021React Summit Remote Edition 2021
33 min
Building Better Websites with Remix
Top Content
Remix is a web framework built on React Router that focuses on web fundamentals, accessibility, performance, and flexibility. It delivers real HTML and SEO benefits, and allows for automatic updating of meta tags and styles. It provides features like login functionality, session management, and error handling. Remix is a server-rendered framework that can enhance sites with JavaScript but doesn't require it for basic functionality. It aims to create quality HTML-driven documents and is flexible for use with different web technologies and stacks.
Don't Solve Problems, Eliminate Them
React Advanced 2021React Advanced 2021
39 min
Don't Solve Problems, Eliminate Them
Top Content
Kent C. Dodds discusses the concept of problem elimination rather than just problem-solving. He introduces the idea of a problem tree and the importance of avoiding creating solutions prematurely. Kent uses examples like Tesla's electric engine and Remix framework to illustrate the benefits of problem elimination. He emphasizes the value of trade-offs and taking the easier path, as well as the need to constantly re-evaluate and change approaches to eliminate problems.
Scaling Up with Remix and Micro Frontends
Remix Conf Europe 2022Remix Conf Europe 2022
23 min
Scaling Up with Remix and Micro Frontends
Top Content
This talk discusses the usage of Microfrontends in Remix and introduces the Tiny Frontend library. Kazoo, a used car buying platform, follows a domain-driven design approach and encountered issues with granular slicing. Tiny Frontend aims to solve the slicing problem and promotes type safety and compatibility of shared dependencies. The speaker demonstrates how Tiny Frontend works with server-side rendering and how Remix can consume and update components without redeploying the app. The talk also explores the usage of micro frontends and the future support for Webpack Module Federation in Remix.
Full Stack Components
Remix Conf Europe 2022Remix Conf Europe 2022
37 min
Full Stack Components
Top Content
RemixConf EU discussed full stack components and their benefits, such as marrying the backend and UI in the same file. The talk demonstrated the implementation of a combo box with search functionality using Remix and the Downshift library. It also highlighted the ease of creating resource routes in Remix and the importance of code organization and maintainability in full stack components. The speaker expressed gratitude towards the audience and discussed the future of Remix, including its acquisition by Shopify and the potential for collaboration with Hydrogen.
Remix Flat Routes – An Evolution in Routing
Remix Conf Europe 2022Remix Conf Europe 2022
16 min
Remix Flat Routes – An Evolution in Routing
Top Content
Remix Flat Routes is a new convention that aims to make it easier to see and organize the routes in your app. It allows for the co-location of support files with routes, decreases refactor and redesign friction, and helps apps migrate to Remix. Flat Folders convention supports co-location and allows importing assets as relative imports. To migrate existing apps to Flat Routes, use the Remix Flat Routes package's migration tool.
How React Router Became a Framework
React Advanced 2024React Advanced 2024
31 min
How React Router Became a Framework
My name is Mark Dalglish and I'm here to discuss how ReactRouter became a framework. Remix is built on ReactRouter and heavily relies on it. Remix feels like a framework because it has a CLI, manages the dev and build lifecycle, and has strong opinions about the file system structure. Remix embraced Vite as a plugin, allowing developers to integrate it seamlessly into their existing Vite setup. The shift to Vite led to a change in the philosophy of Remix Vite, enabling frameworks to orchestrate all the environment builds and make the framework as a plugin pattern first class. React Router is merging with Remix to make all the build time framework features available to React Router consumers. React Router is now officially a framework as well as a library. The move to integrate Remix into React Router is driven by the exploration of the next generation of Remix. React Router V7 simplifies by dropping the React Native layer and allows flexibility for consumers to use it as a library or as a framework with additional architectural features provided by plugins. The focus is on betting on Vite in the long term, and React Router plans to support React Server components. Thank you to Mark for answering the questions.

Workshops on related topic

Remix Fundamentals
React Summit 2022React Summit 2022
136 min
Remix Fundamentals
Top Content
Featured WorkshopFree
Kent C. Dodds
Kent C. Dodds
Building modern web applications is riddled with complexity And that's only if you bother to deal with the problems
Tired of wiring up onSubmit to backend APIs and making sure your client-side cache stays up-to-date? Wouldn't it be cool to be able to use the global nature of CSS to your benefit, rather than find tools or conventions to avoid or work around it? And how would you like nested layouts with intelligent and performance optimized data management that just works™?
Remix solves some of these problems, and completely eliminates the rest. You don't even have to think about server cache management or global CSS namespace clashes. It's not that Remix has APIs to avoid these problems, they simply don't exist when you're using Remix. Oh, and you don't need that huge complex graphql client when you're using Remix. They've got you covered. Ready to build faster apps faster?
At the end of this workshop, you'll know how to:- Create Remix Routes- Style Remix applications- Load data in Remix loaders- Mutate data with forms and actions
Back to the Roots With Remix
React Summit 2023React Summit 2023
106 min
Back to the Roots With Remix
Featured Workshop
Alex Korzhikov
Pavlik Kiselev
2 authors
The modern web would be different without rich client-side applications supported by powerful frameworks: React, Angular, Vue, Lit, and many others. These frameworks rely on client-side JavaScript, which is their core. However, there are other approaches to rendering. One of them (quite old, by the way) is server-side rendering entirely without JavaScript. Let's find out if this is a good idea and how Remix can help us with it?
Prerequisites- Good understanding of JavaScript or TypeScript- It would help to have experience with React, Redux, Node.js and writing FrontEnd and BackEnd applications- Preinstall Node.js, npm- We prefer to use VSCode, but also cloud IDEs such as codesandbox (other IDEs are also ok)
How to Solve Real-World Problems with Remix
Remix Conf Europe 2022Remix Conf Europe 2022
195 min
How to Solve Real-World Problems with Remix
Featured Workshop
Michael Carter
Michael Carter
- Errors? How to render and log your server and client errorsa - When to return errors vs throwb - Setup logging service like Sentry, LogRocket, and Bugsnag- Forms? How to validate and handle multi-page formsa - Use zod to validate form data in your actionb - Step through multi-page forms without losing data- Stuck? How to patch bugs or missing features in Remix so you can move ona - Use patch-package to quickly fix your Remix installb - Show tool for managing multiple patches and cherry-pick open PRs- Users? How to handle multi-tenant apps with Prismaa - Determine tenant by host or by userb - Multiple database or single database/multiple schemasc - Ensures tenant data always separate from others
Build and Launch a personal blog using Remix and Vercel
Remix Conf Europe 2022Remix Conf Europe 2022
156 min
Build and Launch a personal blog using Remix and Vercel
Featured Workshop
Robert Pop
Robert Pop
In this workshop we will learn how to build a personal blog from scratch using Remix, TailwindCSS. The blog will be hosted on Vercel and all the content will be dynamically served from a separate GitHub repository. We will be using HTTP Caching for the blog posts.
What we want to achieve at the end of the workshop is to have a list of our blog posts displayed on the deployed version of the website, the ability to filter them and to read them individually.
Table of contents: - Setup a Remix Project with a predefined stack- Install additional dependencies- Read content from GiHub- Display Content from GitHub- Parse the content and load it within our app using mdx-bundler- Create separate blog post page to have them displayed standalone- Add filters on the initial list of blog posts
Building High-Performance Online Stores with Shopify Hydrogen and Remix
React Advanced 2023React Advanced 2023
104 min
Building High-Performance Online Stores with Shopify Hydrogen and Remix
WorkshopFree
Alexandra Spalato
Alexandra Spalato
I. Introduction- Overview of Shopify Hydrogen and Remix- Importance of headless e-commerce and its impact on the industry
II. Setting up Shopify Hydrogen- Installing and setting up Hydrogen with Remix- Setting up the project structure and components
III. Creating Collections and Products- Creating collections and products using Hydrogen’s React components- Implementing a Shopping Cart- Building a shopping cart using Hydrogen’s built-in components
VI. Building the home page with Storyblok- Cloning the space and explaining how it works- Implementing Storyblok in the repo- Creating the Blok components- Creating the Shopify components- Implementing personalisation
Building a Realtime App with Remix and Supabase
Remix Conf Europe 2022Remix Conf Europe 2022
156 min
Building a Realtime App with Remix and Supabase
Workshop
Jon Meyers
Jon Meyers
Supabase and Remix make building fullstack apps easy. In this workshop, we are going to learn how to use Supabase to implement authentication and authorization into a realtime Remix application. Join Jon Meyers as he steps through building this app from scratch and demonstrating how you can harness the power of relational databases!