Hobo/hobo — pull request #43 by iox (2013-10-09 05:52:29+00:00)
Title: Add speed improvements to development mode

This is a proposal for improving the development load times with Hobo 2.0 and Rails 3.2, focused on what happens after saving a file and reloading a page. This is what I have done:

* Add an option called `hobo.fast_dev_mode `. It disables automatic routes and dryml (forms/cards/pages) generation every time you save a file. If you change the models or the automatic actions you need to restart the app.
* Add an option called `hobo.cached_tags`. You can add a list of tags that you want to cache. This means you don't have to parse again lots of files on every reload, only the ones that have changed. From my tests you can add almost everything here, as Hobo still checks the last modified time before using the cache.
* Add these options and a lot of comments to the template of config/initializers/dryml_taglibs.rb, so it's easier to activate in new applications.

If you are interested in testing this, please:
* Write down the time it takes to reload a page after saving a controller (you can use Firebug for example).
* Change your Gemfile to `gem "hobo", :git => "git://github.com/Hobo/hobo", :branch => 'fast_hobo_dev_reload'`
* Run `bundle`
* Add these lines to `config/initializers/dryml_taglibs.rb`

```ruby
### Speed improvements in development mode ###

# Although with Rails 3.2 dev mode is much faster, after saving a file it still reloads a lot of things
# For example, if you save a controller and reload the page, it can take several seconds to respond
# Same thing with Dryml (very annoying when you are editing and instantly trying the app)

# These are a couple of options to improve performance
# NOTE: You will lose automatic generation of routes and pages/cards/forms (you will need to restart the app)
::Rails.application.config.hobo.fast_dev_mode = true
::Rails.application.config.hobo.cached_tags = ["hobo_bootstrap", "hobo_rapid", "forms.dryml", "cards.dryml", "main_nav.dryml", "pages.dryml"]
# # Along with the previous options, uncomment these lines
Rails::Generators.invoke('hobo:routes', %w[-f -q])
Dryml::DrymlGenerator.run

# # Get rid of an annoying bug in the log
RailsDevelopmentBoost.async = false if defined?(RailsDevelopmentBoost)

# Apart from these, please set these in config/environments/development.rb:
# - config.action_controller.perform_caching = true. This will make work (I recomment to use it in main_nav, as it's a very slow piece of code)
# - config.assets.debug = false. This will reduce the amount of files sent to the browser.

# And more optimizations!
# - Install rails dev boost (https://github.com/thedarkone/rails-dev-boost)
# - Install turbolinks (http://hobocentral.net/blog/2012/12/07/turbolinks/)
```

* Restart your app
* Check how long it takes to load the same page after saving the same controller. You should see a nice improvement ;)

As you can see in the comments, I've also added some extra optimizations you can try.