Currently, requiring gon immediately requires ActionView::Base and ActionController::Basehere for monkey-patching, which results in loading almost everything within actionview and actionpack, and also triggers all :action_view and :action_controller on_load hooks that are defined via apps and bundled plugins.
For postponing those heavy loads, Rails equips ActiveSupport.on_load mechanism as described here. https://guides.rubyonrails.org/engines.html#active-support-on-load-hooks
With this hooks properly configured, applications can defer loading Action*::Base until they actually use them, so that they can boot the app faster where they don't use them, e.g. when starting up the Rails console, running model unit tests, etc.
Currently, requiring
gon
immediately requiresActionView::Base
andActionController::Base
here for monkey-patching, which results in loading almost everything within actionview and actionpack, and also triggers all:action_view
and:action_controller
on_load hooks that are defined via apps and bundled plugins.For postponing those heavy loads, Rails equips
ActiveSupport.on_load
mechanism as described here. https://guides.rubyonrails.org/engines.html#active-support-on-load-hooks With this hooks properly configured, applications can defer loading Action*::Base until they actually use them, so that they can boot the app faster where they don't use them, e.g. when starting up the Rails console, running model unit tests, etc.