Sunday, June 5, 2011

Java script Optimization

1) Minify JavaScript and CSS
2) use CDN's wherever possible
3) use scripts at the bottom of the page (http://developer.yahoo.com/performance/rules.html)
4) CSS sprites for images
5) http://yuiblog.com/blog/2007/01/04/performance-research-part-2/
6) Add an Expires or a Cache-Control Header
7) Put Stylesheets at the Top
8)Make JavaScript and CSS External


http://www.jquery-asp.net/blog/squishit-javascript-and-css-compressor/

YUI


http://www.mattfitz.info/library/article/86



Friday, May 6, 2011

Handling Javascript Event Binding in Ajaxised Page.

We are using MS ajax to add a function that does the rebinds JS events to the elements.

$(window).load(function () {
 Sys.WebForms.PageRequestManager.getInstance().add_endRequest(RunThisAfterEachAsyncPostback);}
        });
This is the function that executes the rebinding code

 function RunThisAfterEachAsyncPostback(sender, eArgs) {
            try {

                if (eArgs.get_error() == null) {
// Rebinding 
                    $("#btnSaveSubScriptions").button();
                    $("#EventsCheckBoxList tbody td").find('input').click(Events_SubClick);
                }
                else {
                    alert("Error Occurred in the System.Please Contact System Admin");
                    alert(eArgs.get_error());
                }                
                
            }
            catch (err) {
                document.write("There are some errors on this page while loading...<br>" + "RunThisAfterEachAsyncPostback");
                document.write("Error is : " + err.description + " <br>Error number is " + err.number);
            }
        };