# What's the best wait for a plugin to autoload

**URL:** <https://www.ruby-forum.com/t/whats-the-best-wait-for-a-plugin-to-autoload/175716>\
**Category:** Rails\
**Created:** [September 18, 2009, 10:39am UTC](https://www.ruby-forum.com/t/whats-the-best-wait-for-a-plugin-to-autoload/175716 "2009-09-18T10:39:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![matthuhiggins](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c68b51/32.png) [@matthuhiggins](https://www.ruby-forum.com/u/matthuhiggins)\
**Post date:** [September 18, 2009, 10:39am UTC](https://www.ruby-forum.com/t/whats-the-best-wait-for-a-plugin-to-autoload/175716/1 "2009-09-18T10:39:22Z")

</div>

Let’s say I have a plugin for for ActionController. I only want the  
plugin loaded if ActionController is loaded.

Rails has put a lot of effort into autoloading only the necessary  
files during startup. Is there a good way for the ActionController  
plugin to load only when the ActionController module is loaded?

For example, most plugins would do the following:

ActionController.class\_eval do  
include UberControllerPlugin  
end

The above lines cause all of ActionController to be loaded for all  
tests and server startups. Is there a way to “autoload” the plugin  
only after the ActionController module has been referenced?
