Sys.WebForms.PageRequestManager add_pageLoaded and performance

1.6k Views Asked by At

I'm having a problem and it shows up in all browsers but is more evident in IE 9 than anything more modern.

I am loading a page using ASP.NET (in some pages there is an update panel). I have the following method:

$(document).ready(function() {
    Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(Refresh);
});

which refreshes page elements. There appears to be a second / sub-second delay though between the time the page has finished loading and the time the first JavaScript method is execute. I wanted to include a loading indicator (basically just pop up a div), for example immediately on page paint. What happens though is the page visibly loads, then there is the small delay, then the indicator (which disappears almost immediately as all JS has executed). I'm thinking the delay might be when the page is painting but I am looking for suggestions. The end user does not want to see the page before the DOM elements have been adjusted using JS.

Thanks in advance.

1

There are 1 best solutions below

0
mquickel On

I worked around this by setting the loadingIndicator's CSS behavior outside of the pageLoaded event (as I assume it is waiting for the DOM to complete loading). This appears to have resolved my problem, thanks.