Pages

Friday, May 22, 2009

web performance: have you tried this?

DEFER Your Scripts

DEFER is a relatively obscure attribute of the script element, but the performance-minded page author can use it to indicate to Internet Explorer 4.0 or later that the script tag contains no immediately executing code that impacts the document before the load event fires. Combined with the SRC attribute, the DEFER attribute can be used on a script tag to indicate to Internet Explorer that the associated code should be downloaded in the background while the rest of the components of the page are downloaded and parsed.

<SCRIPT DEFER>
function test1()
{
   // function which is not required at time page load/start  immediately

}
</SCRIPT>

 

Author Hyperlinks Consistently

The Internet Explorer cache is case-sensitive. That means that you should author your hyperlinks with case-sensitivity in mind. Take the following example.
<A  HREF="/workshop/author/dhtml/reference/dhtmlrefs.asp">DHTML References</A>
<A HREF="/Workshop/Author/DHTML/Reference/DHTMLRefs.asp">DHTML References
Both hyperlinks refer to the same page. Or do they?
On a UNIX system these hyperlinks might refer to two distinct pages; thus, Internet Explorer treats them distinctly by making separate requests to the server, allowing the server to decide how to resolve the request.

By authoring your hyperlinks consistently, you'll be saving space in the user's cache, and you'll be reducing the number of times Internet Explorer has to request the same resource from the server.

Close Your Tags

Unlike XML, HTML has the notion of implicitly closed tags. This includes frame, img, li, and p. If you don't close these tags, Internet Explorer renders your pages just fine. If you do close your tags, Internet Explorer will render your pages even faster.

It is tempting to author in the following way.

<P>The following is a list of ingredients.
<UL>
<LI>flour
<LI>sugar
<LI>butter
</UL>But the following will be parsed more quickly because it is well-formed and Internet Explorer doesn't need to look ahead to decide where the paragraph or list items end.

<P>The following is a list of ingredients.</P>
<UL>
<LI>flour</LI>
<LI>sugar</LI>
<LI>butter</LI>
</UL>

 

Leverage the HTTP Expires Header

The expires header is part of the HTTP 1.0 specification. When an HTTP server sends a resource such as an HTML page or an image down to a browser, the server has the option of sending this header and an associated time stamp as part of the transaction. Browsers typically store the resource along with the expiry information in a local cache. On subsequent user requests for the same resource, the browser can first compare the current time and the expires time stamp. If the time stamp indicates a time in the future, the browser may simply load the resource from the cache rather than retrieving the resource from the server.

Even when a resource would advertise an expiration date still to come, browsers?including Internet Explorer 4.0?would still perform a conditional GET to determine that the version of the object in the cache was the same as the version on the server. Upon careful analysis, the designers of Internet Explorer determined that this extra round trip was neither optimal nor necessary. For that reason, the behavior of Internet Explorer 5 has been modified in the following way: if the expiry of a cached resource is later than the time of the request, Internet Explorer will load the resource directly from the cache without contacting the server. Sites using the expires header on commonly used but infrequently updated resources will experience lower traffic volumes, and customers using Internet Explorer 5 will see pages render more quickly.

 

how to make sure updated .js files gets refreshed on client machine without clearing temp folder?

normally js files used in web application, are cached in clients machine and suppose if we next release
with some updation to same file on server, client browser will not come to know this change.
So we have to clean its temporary folder or clear browser cache by going into internet option>> tools >> clear brwoser history button explicitly.

but how to avoid this? how to make sure that every time we release or update .js files on server, the newer copy or updated copy gets loaded in clients browser?

here is the way
<script type="text/javascript" src="./javascript/MyScript.js"></script>
this is the normal way we use script tag which
we are going to replace as

<script type="text/javascript" src="./javascript/MyScript.js?v=14-05-2009at16:11:19"></script>
include date and timestamp with filename so that next time it will have different date and time
and it will not find same in cache so that it will load new one....

No comments:

Post a Comment