Raymond Moss

Joined

210 Experience
2 Lessons Completed
0 Questions Solved

Activity

Thanks for sharing this — it’s a really useful topic, especially as Rails apps get more complex and performance becomes more critical.

Adding lazy load hooks to Rails plugins is definitely a smart move if you're trying to reduce boot time and avoid unnecessary memory usage. If you're using ActiveSupport.on_load, it's a great way to defer loading code until the specific framework component is initialized. Something like:

ActiveSupport.on_load(:action_controller) do
  include MyPlugin::ControllerMethods
end

This way, your plugin doesn't pull in Rails components prematurely, and it integrates cleanly when the relevant part of the framework is ready.

Out of curiosity — are you using Zeitwerk for autoloading in your plugin? It plays really nicely with this approach if your plugin is structured properly. I’d love to hear how you're organizing things or if you're hitting any snags with it.

Again, awesome share. This kind of insight helps keep the community sharp.