title: What to do with Javascript files needed when rendering an asp.net MVC ChildAction
body: <p>I have a pretty intensive call to a Child Action, with a massive amount of c# code simply called in a few views by:</p>
  
  <pre><code>@Html.RenderPartial("mychildAction")
  </code></pre>
  
  <p>Now I need to load some javascript file whenever this action is called. I can not put the  tags inline (inside the view) because Jquery (and other JS libraries) aren't loaded until the end of the html page.</p>
  
  <p>The (master) _layout should be aware that this ChildAction was called.  But it isn't because a Child Action gets a new HttpContext.</p>
  
  <p>The only solution I came up with, is to switch to a partial (including a big chunk of c# code into the partial and add a few strings to some custom object kept in the HttpContext.Current.Items and make my _Layout act appropriatly).  But doing so would mean I have no output caching on this ChildAction and I throw in bad practices like code in partials.  </p>
  
  <p>What is the best way to handle this scenario?</p>