...

/

Javascript Is a Serious Liability

Javascript Is a Serious Liability

Learn the reasons why incorporating JavaScript can present challenges within a Rails application.

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 serious liability than our Ruby code.

  • Embrace server-rendered views wherever ...