<!-- Add this to your Rails app's body tag -->
<body data-controller="<%= request[:controller] %>" data-action="<%= request[:action] %>">
// Run a function on $.ready of every page
Loader.register(yourCallbackHere) // or
Loader.register('ready', yourCallbackHere)
// Run a function on $.ready of every page in the Welcome controller
Loader.register('welcome', yourCallbackHere)
// Only run a function on the 'index' action of the Welcome controller
Loader.register('welcome:index', yourCallbackHere)
// Run a function after every other function has run
Loader.register('ready:done', yourCallbackHere)
// Run a function on multiple controllers, actions, etc..
Loader.register(
['welcome', 'registration:show', 'dingus:index'],
yourCallbackHere
)