Application.js is not reloading

Video to explain the issue: application.js is not getting re-rendering on page change (

I’ve installed flatpickr and included it in my importmap.rb. It initializes correctly on the initial page load, but doesn’t reinitialize when the page changes. This issue might be due to application.js being cached and not re-rendering with each page load.

After doing my research the problem was the following: In Rails 7, Turbolinks and Rails JS are replaced by Hotwire’s Stimulus and Turbo. This transition can lead to JavaScript events not triggering after the first page load. The reason is Turbo’s alteration of the standard page loading mechanism, potentially hindering the firing of some events.

The solution is the following: you should use document.addEventListener("turbo:load", function() {...})