documentcloud / jammit

Industrial Strength Asset Packaging for Rails
http://documentcloud.github.com/jammit/
MIT License
1.16k stars 197 forks source link

add a way to set a flag to have the page load with unminified javascript #104

Closed ryankshaw closed 13 years ago

ryankshaw commented 13 years ago

In production, I would love a way to set a cookie or a url query param to tell it to load the page with un-closure-compiled javascript, so I can actually have some idea of how to debug it. in other words, have it do what it does in development environment, and not send things through closure-compiler (or yui, if that is what you are using). it would be really nice to have a on-the-fly way of seeing that javascript in an unminified state.

they way I would propose doing this is to have a way to set a query param in the url (something like ?jammit_unminified=true) or to have it check a certain cookie is set. and if so, send the page in the same way it does in development, with each js file separately and in its original, unminified, state. The query param way would be a good way to limit the effect of the setting to just the current page load, and I could see the cookie way being good if you want it to persist through each page load of your session. I vote for whichever one would have the least amount of performance impact of normal requests.

jashkenas commented 13 years ago

Alright -- a version of this is now on master, and will go out with the next release. For any request, you can set:

debug_assets=true

... as a query parameter, in order to receive the development versions of your asset files. If you really need to keep your source code obfuscated, and want to disable this debugging, you can add:

allow_debugging: no

... to your assets.yml file.

ryankshaw commented 13 years ago

sweet, thank you Jeremy. that is exactly what I have been wanting for some time. Can I just say that I really like jammit, it is quite a nifty little too.