Fix: UpdatePanel Async Postbacks Slow in Internet Explorer

We've seen a few issues recently where customers were experiencing very slow async postbacks via an UpdatePanel, but only in Internet Explorer. Other browsers worked fine. (When I say "very slow", I mean in the neighborhood of 30 seconds!) The cause for this isn't a mystery to us.

Because of the way our HTML viewer (mshtml.dll) was designed, Internet Explorer is slow to iterate through large DOM collections. As it happens, the PageRequestManager class has a method called _destroyTree that does just that. It uses a for loop to iterate through all of the DOM nodes in the UpdatePanel's DIV. It does this on the client (the browser) before the request to the Web server is ever kicked off, and if you have a large DOM in your UpdatePanel, you might see a very long delay in Internet Explorer when this occurs.

If you're experiencing this kind of problem, I have good news. We've fixed this for the next version of ASP.NET, and we also have some code that you can use in your applications now to mediate the problem. You can find the updated code in our Knowledge Base at

Update 9/29/2009:
Removed the code from this blog post and referenced KB instead. We did this so that we can service the KB article without having to update this post in the future.


Comments (29)

  1. velio says:


    The code is broken.

    Opening curly brace of function body is missing and it gives JS error on the page.

    Looking forward for the proper code.

    Thanks in advance.


  2. Jim Cheshire says:

    Sorry about that, Velio. Must have been a stray keystroke when I transferred it over. I’ve fixed it.


  3. velio says:

    Great job and tremendous piece of code, Jim.

    Initial usage and tests shows fantastic improvements on UpdatePanel performance.


  4. Jim Cheshire says:

    Thanks, Velio. The credit goes to our product group. I appreciate the update.


  5. trung pham says:

    This is really great. Yes it save a lot of loading page in update panel. Thank you very much

  6. PeteB says:

    This is fantastic, my web page works like a dream now.  

    I have been delaying a release of a whole batch of changes due to slow postbacks and you have just saved me from rewriting the whole page using webservices and other time consuming developments.  Great stuff.

  7. peter cefalu says:

    I am getting a js error ‘nodetype’ is null or not an object. Any thoughts?

  8. Jim Cheshire says:


    Do you have a URL or can you share your page?


  9. Peter Cefalu says:

    No I do not. I did see that you had updated code in your Knowledge Base article and changed it. That fixed the error but my update panels seem even slower. I am not even hitting a DB or anything. Just updating labels with user selections in a form, kind of a summary of what was selected. We use IE6 as this company has not even updated to IE7 yet. Although it is slow in IE7 and 8 as well. Probably just my code. It is instantaneous on my development machine. I was surprised at how slow it is on the live server. It kind of makes it useless now. Oh well, live and learn.

  10. Jim Cheshire says:

    Couple of things, Peter. First of all, if the code is entered correctly, you shouldn’t get an error whether you’re using the latest updated code or the previous code. All I can guess is that there must have been a typo.

    If you are still experiencing slowness, it’s not caused by this issue. If you want assistance in tracking it down, you can open a support incident with us and we can help.


  11. Peter Cefalu says:

    Well Jim,

    I triple checked the code and kept getting the error. It obviously did not like something in the page. There was no typo, but thanks for assuming I am an idiot. The latest version does not throw the error. I do agree that something else is causing the slowness. I am afraid I cannot share any code with you to help fix this problem. Thanks for the offer. And it was a good idea to remove the code from here if it was not being updated.

  12. Jim Cheshire says:

    Sorry you took it that way, Peter. I certainly wasn’t assuming you were an idiot. Because the code was tested thoroughly and is in use by many people without any errors, I surmised that you might have a typo. I would never say someone is an idiot for having a typo! I’ve had pelnty of them myself. 🙂 Everyone does.

    We are updating the code if we can improve on it, but we wanted to make sure to have it in only one place so that it didn’t have to be updated twice. The code is available in the KB article linked on this post.


  13. Peter Cefalu says:

    I really did not take it that way, just my dry humor I guess. I’m just really bummed that it did not help me. I showed the boss the functionality on my machine (where it is super fast) and he loved it. Now it is pretty much useless on the live version until I speed it up. I’ll keep checking for updates though. Thanks.

  14. Jim Cheshire says:

    Understood, Peter. Funny thing is that when I originally posted this blog entry, I had a typo in the code. 🙂

    Yeah, this code is designed to work around a very specific issue. If you don’t see slowness in Firefox, that’s an indicator that it may be this issue.

    We have a lot of skill in troubleshooting performance issues like yours, so if you reach a dead end, open a case and we can help out!


  15. Volodymyr Goncharov says:

    It is very crucial to put the JavaScript "immediately before the closing </body> element". In other cases it may not work.

    Thanks for the fix!

  16. Honus says:

    I am so happy I want to cry!  Thanks for solving this life-long (or at least the past year) dilemna.

  17. Drazen says:


    I am trying to fix this same issue for last 3 days and still cant manage it. And it is supposed to be simple, just to copy/paste, right:)

    I have master page and I paste it right before closing body tag. Nothing happens, its still very slow on IE. if I paste this function anywhere in child page, in content holders where my update panels are, that causes this problem with IE, still the same. FF and Chrome do all the roundtrip and render it in like 5 secs, and IE takes around 30 secs:) The only thing I succesed to do is to find this piece of code:

    string script = "WebForm_InitCallback=function() {};";

               ScriptManager.RegisterStartupScript(this, GetType(), "removeWebForm_InitCallback", script, true);

    and that code alone saves around 12 secs and now IE is updating my panels around 16-17secs. But if I take update panels out, whole thing lasts for 6-7 secs which is fine(but ugly:) so I assume that this fix-function isnt doing dirty work for me.

    Any help, suggestion?


    did i mention how much i hate internet explorer..:)

  18. J.Shapaka says:

    Thank you so much. Awesome fix.

  19. Pablo H Sandrini says:

    Ups man! it works!! from now on you are God for my!!

  20. Thomas Gielissen says:

    when i paste the script before the </body> tag and I open the related web page i get a Javascript Error.

    Expecting "{".

    On the first line of the script I see

    function disposeTree(sender, args)gs.get_panelsUpdating();

    I’m guessing it should be

    function disposeTree(sender, args)



    When I do this the (on load) javascript error is solved.

    However whenever I do a postback now (eg a button click), I get another javascript error: ‘gs’ is undefined.

    Can somebody tell me what’s wrong? Or am I doing something wrong?

    Thanks in advance!

  21. Jim Cheshire says:


    You need to copy and paste the code from the article. What you’re describing is not the code in our article.


  22. Jim Cheshire says:


    If you have followed the directions in the article exactly and it hasn’t resolved your problem, I can only surmise that your issue isn’t caused by this problem. Without any data or troubleshooting, there’s no way to determine what’s wrong.

    If you can’t resolve this on your own, we can certainly help, but you’ll need to open a case via



  23. Jim Cheshire says:


    I notice that what you are showing as "gs" should be "args". I’m not sure what’s doing that. Is the code correct when you paste it but only wrong after your browse via your browser?


  24. Danyal says:

    Drazen’s solution worked for me also. The disposetree script provided had no effect on the performance.

    I also found the root cause to be WebForm_InitCallback, which was taking 10-12 seconds to process the loop (700 elements containing roughly 100 select elements), and it is getting called after the disposeTree function.

    I am using Telerik’s RadGrid and its RadScriptManager.

    I was able to confirm from various posts online that the underlying problem is the processing of the <select> element. If I use only text boxes in the grid, the result shows up in 1-2 seconds.

    I urge you to follow up on Drazen’s solution before you completely disregard it and help us find a solution or at lest tell us the dangers of doing it, if any.

  25. Jim Cheshire says:

    If I’m not mistaken, what Drazen is referring to is this blog post:

    While these folks see a similar symptom, it’s not the same issue I describe in this post. The issue described in the blog post above is not specific to IE. Firefox also sees a long delay and high CPU. I wrote this post specifically to address one issue that is IE-specific.



  26. Vipin says:

    Thanks for this fix , its working like charm.

    Could i use ScriptManager.RegisterStartupScript for rendering this script at the bottom of page(before </form> tag), as i have around 40 pages in my website. I found a difference that when i put this script directly at the bottom(</body>) tag, that method was invoked only once. But through ScriptManager.RegisterStartupScript it was invoked for each and every postback. Is there any problem with registering the script like this?. Which one is correct ? Please help me.

  27. Sanjay says:

    How to use this code in a usercontrol module of DNN?

  28. Kaka says:

    I'm use this code in DotNetNuke, I put it in Default page right after </body> or  an user control has this problem,  but nothing happen. This is my code:

    <body id="Body" runat="server" >

       <dnn:Form id="Form" runat="server" ENCTYPE="multipart/form-data" >

           <asp:Label ID="SkinError" runat="server" CssClass="NormalRed" Visible="False"></asp:Label>

           <asp:PlaceHolder ID="SkinPlaceHolder" runat="server" />

           <input id="ScrollTop" runat="server" name="ScrollTop" type="hidden" />

           <input id="__dnnVariable" runat="server" name="__dnnVariable" type="hidden" />


    <script language="javascript" type="text/javascript">

         function disposeTree(sender, args) {

           var elements = args.get_panelsUpdating();

           for (var i = elements.length – 1; i >= 0; i–) {

               var element = elements[i];

               var allnodes = element.getElementsByTagName('*'),

                   length = allnodes.length;

               var nodes = new Array(length)

               for (var k = 0; k < length; k++) {

                   nodes[k] = allnodes[k];


               for (var j = 0, l = nodes.length; j < l; j++) {

                   var node = nodes[j];

                   if (node.nodeType === 1) {

                       if (node.dispose && typeof (node.dispose) === "function") {



                       else if (node.control && typeof (node.control.dispose) === "function") {



                       var behaviors = node._behaviors;

                       if (behaviors) {

                           behaviors = Array.apply(null, behaviors);

                           for (var k = behaviors.length – 1; k >= 0; k–) {






               element.innerHTML = "";







    Please help me! I need your help very much

  29. Dov says:

    Where should I put the code when using a master page? Should it be put before the </body> tag of the master page or someplace in the child page? If in the child page, where? Thank you.

Skip to main content