Welcome everyone! In this article we will address, in a practical rather than theoretical manner, two new features added by default in Ruby on Rails 7: load_async and turbo_frames.
These two new features will positively revolutionize our web apps, as both aim to address an issue that has always been highlighted with negative connotations in our beloved framework, which is related to the loading of data and subsequent rendering of views. In small or medium-sized projects this is usually at normal and tolerable levels, but as the amount of data and requests grows a harsh reality begins to set in, colloquially expressed by the average person by saying “it becomes slow”.
Addressing this concern and the ongoing performance loss in the RoR community, improvements have been added in this latest version specifically targeting this aspect. New core-level modules and the default implementation of technologies like Hotwire, specifically Turbo (Turbo Drive, Turbo Stream, Turbo Frames), along with a new version of Rack 3 and the use of Falcon as a web server, successfully overcome this recurring problem. This sets the stage for a new era of RoR, showcasing a mature community that constantly strives for improvement with each release.
From our point of view, implementing these techniques may be a bit cumbersome at first, like anything new. It may generate resistance in some developers, but those who dare to follow the steps will quickly notice that the improvements are substantial and worth it.
Two different techniques will be discussed here (among others): one with load_async and another with turbo_frames, both attempting to solve the same problem of improving the user experience when loading and rendering large amounts of data. These are initial steps, and the choice between them will depend on each particular case.
load_async enables the execution of asynchronous requests to the database, reducing wait times and rendering. This could be considered a backend-level technique. Turbo_frames redefine how specific portions of a page are updated and loaded. This advanced technique maximizes turbo frames to load only the necessary fragments, minimizing server load and optimizing the user's navigation speed. We could consider this more of a frontend-oriented technique (clarification: not exclusively frontend).
With that being said, and having provided a bit more context on the matter, here is our video tutorial for asynchronous rails.