title: Can web control RegisterClientScriptResource render after a page's ScriptManagerProxy ScriptReference?
body: <p>I have a web control which requires it's own javascript so it uses RegisterClientScriptResource called from OnPreRender to render a script tag when the page renders.</p>
  
  <p>The web controls javascript depends on jquery.  However to allow for different versions of jquery it does not embed the jquery javascript itself.  Instead it relies on the web application to reference the appropriate jquery script.  So to do that My page has a ScriptManagerProxy with a ScriptReference to the jquery js file.</p>
  
  <p>When the page renders, I get a script tag referencing the web controls script followed by a script tag referencing the jquery file:</p>
  
  <pre><code>&lt;script src="/MyApp/ScriptResource.axd?d=D9drwtSJ4hBA...qGfE1&amp;amp;t=ffffffffc7ae6e38" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="Scripts/jquery-1.10.2.min.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="Scripts/jquery-ui-1.11.1.min.js" type="text/javascript"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>My problem is the order of script includes needs to be reversed because it extends jquery:</p>
  
  <pre><code>jQuery.extend(jQuery.ui, { mydatepicker: { version: "1.0.0"} });
  jQuery.fn.mydatepicker = function (options) {
  
      ...
  }
  </code></pre>
  
  <p>The current order causes my mydatepicker function to not work.</p>
  
  <p>If I use ScriptManager or ScriptManagerProxy in my page asp.net will render script references in order of hierarchy, so master page script references render first followed by references in it's children then their children all the way down the chain.  I would have expected that the script reference in my web control would render after the others given that the control is the deepest within the hierarchy, but instead it renders first.</p>