6 Web site optimization methods to improve website speed

Source: Internet
Author: User

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

A few colleagues recently opened a personal blog, but complained that because of the purchase of virtual space, so personal blog site open very slowly. For this phenomenon, according to the general situation, the access of a Web site to open faster and slower, this is all about the use of the space configuration, if the space host configuration is good, then your site access speed will be very fast; on the contrary, if your space host is poorly configured, your site will be slow to access. In fact, the allocation of space host not to talk about, we webmaster or SEO personnel can also start from the Web page production, thus from the existing resources to improve access to the site speed. If you do not know how to optimize the site to improve the speed of access to the site, then look at the Ma Haixiang blog for you summed up the six tips bar, I hope you can help!

1, use the browser to cache your JS and CSS files:

Add the following code in the site root directory. htaccess.

Expiresactive on

ExpiresDefault "Access plus 1 year"

This code means that the header cache header is sent to the JPG|GIF|PNG|CSS|JS for a one-year cache, and when the browser does not use the press force flush, it is cached until the time is over. The only regret is that if you change the JS or CSS file must change the previous path or file name, you can do so base.js?ver= (x) This way the next time the browser will automatically read and cache.

2. Replace your. JS library file address with Google CDN's address:

With the use of jquery and MooTools and other JS libraries need to be loaded. js files are becoming more and more large, usually the traditional Web site is uploaded to the site itself directory. But for a nearly 70 KB jquery.js volume does not facilitate the Web site response speed, you should use the Google API.

For example: Replace your http://www.***.cn/jquery.x.x.js with http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/ Jquery.min.js, the point is that when a user accesses a Web site that uses the Google API, it does not need to load the file again to access other sites that have called the API address. So as to speed up the purpose.

Not only jquery library, other such as MooTools Yui can also use this way.

3, streamline and optimize your JS and CSS:

Although the cache and gzip escort, but for JS and CSS optimization is also necessary. The JavaScript script and CSS code we write are both indented and wrapped, suitable for human reading, but browsers do not need these meaningless spaces and line-wrapping to execute these scripts. So we should get rid of some of these whitespace lines and even shorten the variables in JavaScript and CSS. Such optimization tools have YUI compressor and Closure Compiler. Both of these tools are java-based, using the JDK that should be installed and setting up Java_home. (It's a bit difficult for non-programmer webmasters)

This tool can not be installed in the local JDK, directly upload JS and css file compression, you can choose to use YUI compressor or Closure Compiler.

4, GZIP compressed your JS and CSS files:

Compressed JS and CSS can be done through the server dynamic script can also be simpler to use the Apache server can be in the site root directory. htaccess the following code

Addoutputfilterbytype DEFLATE html text/css filetype by Application/x-javascript Application/json

Header Append Vary accept-encoding

This code means that the call to the server's compression module on the above file output gzip compression, gzip after the compression of all files should be able to reduce the volume of more than 30%. Especially for a large number of Use JS blog has gzip escort after the speed can be improved a lot.

5. Use CSS sprites to merge pictures

A website often uses small icons and small pictures to beautify, but unfortunately these small pictures occupy a large number of HTTP requests, so you can use the Sprites way to merge all the pictures into a picture, can be merged through the relevant tools online, can also be merged in PS.

6, optimize your website picture:

Although the use of a large number of pictures and icons can bring stunning results to the site, graphics and text mixing is a very beautiful way to display the blog. But the size of the picture is really not very strong, JPG is a lossy compression format, while PNG is lossless, but the flaw is quite large. In order to reduce the picture volume to achieve the fastest download speed, each picture should be optimized before uploading the volume.

This article for Ma Haixiang Blog original article, if you want to reprint, please indicate the original site is excerpted from http://www.mahaixiang.cn/wyzz/207.html, annotated source;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.