开发者

how to decrease the loading time of web pages?

I made PHP website.It has 100 webpages but when I open it..It takes lots of time for load.This is static website not dynamic.but content size in the pages are larger..It takes more loaing time in web browse.

What can I do for decrease the loading time..Please give me开发者_开发技巧 solution.


There is a very beautiful tool available to monitor what you have asked named as Yslow

Have a look at this.


There are a whole variety of methods here:

  • If you are accessing a database look at optimising your queries, for example specify only the fields that you need in a SELECT query rather than using SELECT *

  • Employ some form of server-side caching. There are a number of solutions for PHP - see this site for more details http://www.sitepoint.com/caching-php-performance/

  • Use client-side (browser) caching by setting appropriate Cache HTTP headers (see http://www.mnot.net/cache_docs/ for more details)

Without further information about your site it's difficult to provide a more specific answer.


test your site in chrome It has a great feature wich shows what time elements take to load. ( ctrl shift i , timeline)


Short steps for full optimization are

1) Backend

  • Should be Analysis and reduce the Data fetching time using index, reduce subquerys, temptable etc..

2) Frontend

  • reduce big size library Js scripts
  • Image size
  • Php scripts looping (page loading check out using browser plugin)
  • Reduce the html size as well.

3) its really funny but also need to check. Please check out your broadband and network capacity...

Those thing u have done all the page will come good...


You should optimize query and database operations. you should always prefer to complete things in minimum no. of loop if possible..

loading time is also affected by the page content. you should eliminate unnecessary images from form..

it also affected by server speed if you are running on server..


Simple answer, if there's too much content, then reduce the content on the page! Install YSlow and follow its advice.

To be more specific, you need to apply some rules and show some self-control to keep loading times down. There's also stuff you can do on the PHP side, but we'll get to that later. On the client side, the following tips will help.

Remove any markup that isn't necessary. For example,

<div class="class 1>
  <div class="class 2">
    <div class="class 3">
        <p> Hello, I'm the content</p>
    </div>
  </div>
</div>

With judicious use of CSS you can in most cases replace this with

<div class="class1 class2 class3">
  <p>Hellp, I'm the content!</p>
</div>

You could even ditch the div altogether, if it's only ever going to contain a single child.

<p class="class1 class2 class3">Hello, I'm the content!</p>

Images: Rule of thumb is no image on a web page should exceed 100K in size. While there are exceptions, this is a good rule to stick to. If you have many or large images on your page, try optimizing them. Replace lossless formats with lossy ones,(Truecolour PNG with JPEG) replace older file formats with modern ones with better compression (GIF with non-truecolor PNG), lower image quality settings for JPEG, reduce number of colours in PNG, and so on.

NEVER use BMP images on a web page!

You can speed up page loads by reducing the number of HTTP requests being made. Every asset on your page (image, stylesheet, javascript file, etc) represents a HTTP request, and the specs say you can only have 2 requests open at any one time. Any additional requests will be queued up until the first ones are cleared.

You can reduce the number of requests by, for example, having a single stylesheet for your page instead of multiple ones (though be sensible here, some stuff is better kept in a separate sheet, such as IE fixes), using image sprites, combining javascript files together (again, be sensible). and so on

One thing that won't speed up page load times, but will make them more responsive is to put all your javascript at the bottom of the page (just before the </body> tag) as loading javascript in the head or higher up in the body will force the browser to wait until the JS has been evaluated before rendering what comes after it.

On the server side, turn compression on. Make sure files are sent with suitable cacheing headers so the browser can cache images, stylesheets, javascript, etc.

Finally in PHP, optimize your code so that it generates output more quickly. The server can't start sending content to the client until the PHP script has generated it. This usually means optimizing SQL queries to execute faster.

Finally, if the pages don't change that much, have PHP cache a copy of the output to disc, and send the cached version on subsequent page loads. When the page content is changed, have the PHP script delete the cached version. The fastest query is the one you don't have to run :)


To Speedup the website try to do the following

  1. Avoid HTTP requests.To avoid the direct request for the CSS, JS and others,include those in our project itself
  2. Avoid the Bulk request from the database.To be more specific,(eg: SELECT *) Include only the relevant data field from the database table
  3. Optimize Images.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜