How to register a client script resource at the bottom of webpage to enhance loading time

I really hate the way Extender controls, script controls that emit javascript all at the top of the web page and just was rethinking of any other way to emit it at the bottom similar to what,
ClientScriptManager.RegisterStartupScript. On looking into this post by DanWahlin i think it is possible but i would have to handle all dirty work of seeing of script is included twice and making sure all necessary scripts are included in order. So my question boils down to this

“I am developing custom controls, Extender controls and i want all my scripts emitted to be at bottom of webpage, What options do you suggest and Why”

  • Running Internet Explorer with “Run as” fails to open a new PDF window
  • JQuery to loop through a variable number of items in an asp repeater
  • Add Html.Partial to Javascript
  • JavaScript minifyer which can be integrated with a build of an ASP.NET application
  • KendoUI line Graph, How to keep labels from being drawn outside the graph?
  • How to implement Validation Controls with multiple submit buttons
  • Note:
    These scripts and also css are embedded as web resources

  • How to Get all users from Office Communicator to web page?
  • DateTime in jqGrid PostData while RelaodGrid Operation
  • ASP.NET alert newline from CodeBehind
  • How to add class (active) on specific “li” on user click with jQuery
  • If DropDownList Selected Index Changed, hide gridview rows
  • change color of special characters in HTML
  • 3 Solutions collect form web for “How to register a client script resource at the bottom of webpage to enhance loading time”

    As long as we are talking about MS AJAX Toolkit there is an option in the Toolkit ScriptManager that is called “LoadScriptsBeforeUI”. Setting this to “false” would allow you to get your UI loaded before the scripts, if this is your goal.

    I am generally wondering why having scripts in the top of a webpage would bother you, for it is a general practice and you see any impact only if your connection is extremely slow.

    AFAIK you have to handle the OnRender part of the page.
    I was doing something similar but to move the viewstate of the page for SEO thing

     protected override void Render(System.Web.UI.HtmlTextWriter writer)
      System.IO.StringWriter stringWriter = new System.IO.StringWriter();
      HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);
      string html = stringWriter.ToString();
      int startPoint = -1;
      int endPoint = -1;
      startPoint = html.IndexOf("<input type=\"hidden\" name=\"__VIEWSTATE\"");
      if (startPoint >= 0)
        endPoint = html.IndexOf("/>", startPoint) + 2;
        string viewstateInput = html.Substring(startPoint, endPoint - startPoint);
        html = html.Remove(startPoint, endPoint - startPoint);
        int FormEndStart = html.IndexOf("</form>") - 1;
        if (FormEndStart >= 0)
          html = html.Insert(FormEndStart + 1, viewstateInput);        

    Maybe you can do the same lokking for script tag. Other way I can thing of is to put a <%=MyVar%> at the end of the page, so you can set it from the code behind, but I guess is too much couplig with the page

    Actually speaking you can’t with the current implementation of the ajax extender controls. So i managed to rely on client script dependency framework like script.js instead. I did achieve that i wanted.