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.

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 new web framework from the creators of React Router that helps you build better, faster websites through a solid understanding of web fundamentals. Remix takes care of the heavy lifting like server rendering, code splitting, prefetching, and navigation and leaves you with the fun part: building something awesome!
Don't Solve Problems, Eliminate Them
React Advanced Conference 2021React Advanced Conference 2021
39 min
Don't Solve Problems, Eliminate Them
Top Content
Humans are natural problem solvers and we're good enough at it that we've survived over the centuries and become the dominant species of the planet. Because we're so good at it, we sometimes become problem seekers too–looking for problems we can solve. Those who most successfully accomplish their goals are the problem eliminators. Let's talk about the distinction between solving and eliminating problems with examples from inside and outside the coding world.
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
Do you have a large product built by many teams? Are you struggling to release often? Did your frontend turn into a massive unmaintainable monolith? If, like me, you’ve answered yes to any of those questions, this talk is for you! I’ll show you exactly how you can build a micro frontend architecture with Remix to solve those challenges.
Full Stack Components
Remix Conf Europe 2022Remix Conf Europe 2022
37 min
Full Stack Components
Top Content
Remix is a web framework that gives you the simple mental model of a Multi-Page App (MPA) but the power and capabilities of a Single-Page App (SPA). One of the big challenges of SPAs is network management resulting in a great deal of indirection and buggy code. This is especially noticeable in application state which Remix completely eliminates, but it's also an issue in individual components that communicate with a single-purpose backend endpoint (like a combobox search for example).
In this talk, Kent will demonstrate how Remix enables you to build complex UI components that are connected to a backend in the simplest and most powerful way you've ever seen. Leaving you time to chill with your family or whatever else you do for fun.
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
This talk introduces the new Flat Routes convention that will most likely be the default in a future version of Remix. It simplifies the existing convention as well as gives you new capabilities.
Remix Architecture Patterns
Remix Conf Europe 2022Remix Conf Europe 2022
23 min
Remix Architecture Patterns
Top Content
Remix provides amazing flexibility and can be deployed anywhere where JavaScript is running. But how does Remix fit into the bigger application landscape of an organization? Remix provides great utility, but how to best take advantage of it? What things should be handled inside of Remix, and what things are better off done elsewhere? Should we use the express adapter to add a WebSocket server or should that be a standalone microservice? How will enterprise organizations integrate Remix into their current stacks? Let’s talk architecture patterns! In this talk, I want to share my thoughts about how to best integrate Remix into a greater (enterprise) stack.

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 Conference 2023React Advanced Conference 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!