Thursday, October 23, 2008

Improve Performance of Website (Part-2)

Hey!! i'm back with the second part of the series.....

Let's start!!

* The JavaScript and CSS files are cached by the browser. So, using them as external files generally produces faster pages.Js and CSS that are inlined in HTML docs get downloaded everytime the HTMl doc is requested. This reduces the number of HTTP requests, but increases the size of the HTMl doc. but using JS and CSS in external files reduces the size of the HTML doc without increasing the number of HTTP requests.

Inlining is preferable only with the home pages which have only one page view per session. Inlining in this case results in faster end-user response time.


* The other method is Flush the buffer. When user requests a page ,it takes arount 200 - 500ms for the backend server to stitch together the entire HTML page. And during this time the browser is idle.Some languages rpovide functions to flush the buffer. For Eg. In php we have flush(). It allows you to send partially ready HTML response to the browser, so that the browser can start fetching components while your backend is busy with the rest of the page.

A good practice is to place the flushing right after the HEAD coz it is easier to produceand it also allows you to include any CSS and JS files for the browser to start fetching in parallel while backend is procesing.


... < !-- CSS , Javascript -->
</head>
<?php flush(); ?>
<body>
... <!-- Content -->


Enjoy and Have Fun!!


Please Comment!!

No comments: