Search⌘ K
AI Features

Javascript Is a Serious Liability

Explore the challenges JavaScript introduces in web app development with Rails. Understand why JavaScript is a more serious liability than backend Ruby code due to its unpredictable runtime, difficulty in error observation, and an unstable ecosystem. Learn to manage these issues by minimizing JavaScript use and favoring server-rendered views, improving app sustainability and reliability.

Overview

JavaScript and front-end development is a deep topic. We won’t be able to cover it all here, and we can’t give a guide on sustainably creating highly complex dynamic web applications that run entirely in the browser. The good news is that we almost certainly don’t need our application to work that way. At best, we’ll need what Zach Briggs calls “islands of interactivity,” i.e., bits of dynamic behavior, on some of our pages.

The single best thing we can do to keep our front-end sustainable is to use only what JavaScript we actually need to deliver value to the app’s users. There are a lot of current realities about client-side JavaScript and web browsers that make it inherently more difficult to work with than back-end technologies.

In this chapter, we’ll focus on JavaScript generally: how to think about it and manage it at a high level. The overall strategy here is:

  • Understand why JavaScript is a more ...