Right way to add JS and CSS to node/edit and other forms I am making a site with a lots of JS, and I am wondering where I should put the JS code. Optimally I would like to keep the JS with each module and not the theme layer. Some content could be exposed as blocks etc. 

But I am having some issues with the cache. In my example I need to add JS &amp; CSS to the node edit form. I have used hook_block_view, but it is cached. So if there is an error in the node edit form, the drupal_add_js &amp; drupal_add_css functions are not called. The same seems to be true for hook_node_prepare.

Where would you input the JS &amp; CSS layer? and are there hooks that get's called even if there is an error in the node edit form?
If you wish to add JS and CSS to the node edit page in particular (or any form in general), the best and the right place to do so is the hook_form_alter() and the property you should be using is #after_build.

This comment on DO tells you exactly what to do - http://drupal.org/node/1253520#comment-4881588

Hope this helps :-)