SYSK 326: How to Measure AJAX Control Initialization Time on the Client Side


Say, you’ve added a few extender controls to make your AJAX-enabled web site look very ecstatically appealing to the end users.  And now you’d like to evaluate the cost of beautifying your site in such manner.  Measuring the additional page size bytes is pretty straight forward, so is the page load time… But how would you measure the time it takes for the browser to initialize these extra controls?


 


Here is the best way I know how:


 


<script type=”text/javascript”>   


    var t1;


   


    var prm = Sys.WebForms.PageRequestManager.getInstance();  


    Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(pageLoadedHandler);


                   


    function pageLoadedHandler(sender, args)


    {           


        t1 = new Date();       


    }


   


    window.pageLoad = function()


    {


        alert(“AJAX control initialization took “ + ((new Date()).getTime() – t1.getTime()) + ” ms”);


    }


</script>


 


 


Important: The logic above depends on the AJAX client side initialization implementation; i.e. the code above may or may not work in future AJAX releases.


 


 

Comments (1)

  1. More and more web sites are using rounded corners on spans (labels) and panels. And since AjaxControlToolkit

Skip to main content