title: What is a clean pattern for keeping all the JavaScript in the bottom of my page?
body: <p>We have a nested layout for our various pages. For example: </p>
  
  <p><code>Master.cshtml</code></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
     &lt;head&gt;...&lt;/head&gt;
     &lt;body&gt;@RenderBody()&lt;body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><code>Question.cshtml</code></p>
  
  <pre><code>&lt;div&gt;
    ... lot of stuff ...
    @Html.Partial("Voting", Model.Votes)
  &lt;/div&gt;
  &lt;script type="text/javascript"&gt;
    ... some javascript ..
  &lt;/script&gt;
  </code></pre>
  
  <p><code>Voting.cshtml</code></p>
  
  <pre><code>&lt;div&gt;
    ... lot of stuff ...
  &lt;/div&gt;
  &lt;script type="text/javascript"&gt;
    ... some javascript ..
  &lt;/script&gt;
  </code></pre>
  
  <p>This all works fine, but I would like to push all of the JavaScript blocks to be rendered in the footer of the page, after all the content. </p>
  
  <p>Is there a way I can define a magic directive in nested partials that can cause the various script tags to render in-order at the bottom of the page? </p>
  
  <p>For example, could I create a magic helper that captures all the js blocks and then get the top level layout to render it: </p>
  
  <p><code>Voting.cshtml</code></p>
  
  <pre><code>&lt;div&gt;
    ... lot of stuff ...
  &lt;/div&gt;
  @appendJSToFooter{
     &lt;script type="text/javascript"&gt;
       ... some javascript ..
     &lt;/script&gt;
  }
  </code></pre>