I have been a fan of UJS for the longest time and I usually put ALL my code in application.js(jquery, not prototype)

However, I have come across a huge project that will bloat up application.js if left untended and I don't want that to happen, especially since most of my functions/behavior will be based on specific pages. Right now, I am inclined to put the javascript calls on specific partials, like so:

on \_test\_partial.html.haml:

```
%p= link_to "Expand All", '#', :class => "expand-categories"

:javascript
  $(function() {
    $('.expand-categories').click( function() {
      $(".test-cases").slideToggle();
      return false;
    })
  })

```

Or if I really wanted "unobtrusive" stuff:

```
%p= link_to "Expand All", '#', :class => "expand-categories"

= javascript_include_tag 'test-categories.js'

```

But it seems to me that this is still very obtrusive, as if I have to edit the code/behavior, I will have to look for the partial concerned. On the other hand, isn't that easier that scouring a 1MB(there are lots of pages and there will probably lots of page specific code) application.js of a function i need to edit.

What's the usual take on this? Is there a way for me to name a js file ala RJS like test\_partial.js.erb os something?