title: ASP.NET MVC Html Helper Extensions and Rendering Their Required "include"s
body: <p>I have build a custom Html Helper extension as follows:</p>
  
  <pre><code>public static string DatePicker(this HtmlHelper helper, string name, string value)
  {
          return string.Format(@"&lt;script type='text/javascript'&gt;
  $(document).ready(function(){{
      $('#{0}').datepicker({{ 
          changeMonth: true, 
          changeYear:true, 
          dateFormat: 'd-M-yy', 
          firstDay: 1, showButtonPanel: 
          true, 
          showWeek: true 
      }});
  }});
  &lt;/script&gt;
  &lt;input type='text' name='{0}' id='{0}' value='{1}'&gt;", name, value);
  }
  </code></pre>
  
  <p>The problem is that this now requires the page to "include" the following:</p>
  
  <pre><code>&lt;script src="/Scripts/jquery-1.4.2.min.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="/Scripts/jquery.ui.datepicker.min.js" type="text/javascript"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>And a few other items. The questions are as follows:</p>
  
  <ol>
  <li><p>Is there a serious processing
  overhead if I were to include these
  items in EVERY page (like in the
  Site.Master for example) thus
  negating the need for the HtmlHelper
  to organise the "includes" -
  considering there would end up being
  about 20 includes for all the
  different types of jQuery UI widgets
  used throughout the site.</p></li>
  <li><p>If the HtmlHelper sorts out the
      "includes", it will add one every
      time this DatePicker is used (often
      there are two on a page) Does anyone
      have a way of determining whether or
      not the user has already rendered
      the same type of control on the
      page, thus not re-including the same
      jquery libraries when multiple
      instances of the DatePicker (for
      example) are used?</p></li>
  </ol>