Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


to_prepare block runs for every sprockets asset request #1530

nathansobo opened this Issue · 3 comments

4 participants


When requiring javascript with the :debug => true option in development mode, the many small asset requests are unduly slowed down by the execution of the to_prepare block before each of them. It would be nice to not execute this block if a request is being handled by sprockets, to optimize loading of individual js files while retaining convenient class reloading for normal requests.


I agree. In particular, Mongoid will preload all models for every request if preload_models is set. This drastically slows down development.

@jake3030 jake3030 referenced this issue from a commit in jake3030/rails
Ben Symonds Change field_changed? method to handle the case where a nullable inte…
…ger column is changed from 0 to '0'

[#1530 state:committed]

Signed-off-by: Jeremy Kemper <>

Here's a gem that'll turn off to_prepare on each asset request: (also configurable for any other request you like). Gives a good boost.


There is no way to_prepare callback can be disabled only for sprockets in a reliable way and avoiding side effects. This should be done at your own peril and not automatically by Rails. Honestly, Mongoid could do better than preloading all models on each request (it could be lazy, for instance).

@josevalim josevalim closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.