In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces how to improve the speed of website access, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to understand it.
1. Replace your .js library file address with the address of Google CDN:
(google apis's current visit to China is not very stable, so it is not recommended to use this article.)
As more and more .js files need to be loaded with the use of js libraries such as jquery and mootools, traditional websites are usually uploaded to the directory of the site itself. However, for a jquery.js volume close to 70 KB, it is really not conducive to improve the response speed of the website, so Google API should be used at this time.
The point of replacing your http://www.cnblogs.com/jquery.x.x.js with http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js is that when a user visits a site that uses google api, he or she does not need to load the file again when he visits another site that calls the api address. In order to achieve the purpose of speed up.
Not only jquery libraries, but others such as mootools yui can also use this approach.
Recommend a website (http://scriptsrc.net/) that collects the js API paths provided by Google. Click copy directly to get the latest version of the file path.
two。 Streamline and optimize your js and CSS:
Although there is a cache and gzip escort, but for js and css optimization is also necessary. The javascript scripts and css code we write are indented and wrapped and suitable for human reading, but browsers don't need these meaningless spaces and line breaks to execute these scripts. So we should remove these space line breaks and even shorten the variables in javascript and css. Such optimizers have YUI Compressor and Closure Compiler. Both tools are based on java, and you should install jdk and set up JAVA_HOME when using it. (it's a little difficult for non-programmer webmasters.)
Recommend an address (http://sweet.fengyin.name/?hl=zh-CN)
This tool can upload js and css files for compression without installing jdk locally, and you can choose to use YUI Compressor or Closure Compiler.
Through YUI Compressor or Closure Compiler and compressed code such as
Function hello (name) {
Alert ('hello blog' + name)
}
Hello ('Garden')
It will become
Function hello (a) {alert ("hello blog," + a)} hello ("Garden")
Your indentation and blank lines are removed and the variable names are also shortened. This optimization is irreversible, so please back up a source file before using these two compressions to facilitate future modifications.
3.GZIP compresses your JS and CSS files:
Compressing js and css can be done through a server dynamic script, or it can be easier to use the apache server. You can add the following code to the site root .htaccess
AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml application/x-javascript application/json
Header append Vary Accept-Encoding
This code means that the compression module of the server is called to compress the above files before GZIP compression. After gzip compression, all files should be able to reduce the volume by more than 30%. Especially for blogs that use a lot of js, the speed can be improved a lot with gzip escort.
4. Cache your js and CSS files:
Add the following code to the root of the site. Htaccess
ExpiresActive on
ExpiresDefault "access plus 1 year"
This code means to send header cache header to jpg | gif | png | css | js, which will be cached for a year and will be cached until the end of time when the browser is not forced to refresh using ctrl+F5. The only pity is that if you change the js or css file, you have to change the previous path or file name, so that base.js?ver= (x) will be automatically read and cached by the browser next time.
5. Use css sprites to merge pictures
A website often uses small icons and small pictures to beautify, but it is a pity that these small pictures take up a large number of HTTP requests, so you can use sprites to merge all the pictures into one picture. Http://csssprites.com/ can be merged online or in ps through this URL.
For more information on css sprites, please see http://baike.baidu.com/view/2173476.htm.
6. Optimize your website pictures (pictures):
Although a large number of pictures and icons can bring beautiful results to the website, the mixed compilation of pictures and texts is a very gorgeous way to show blog posts. But the volume of the picture is really not very powerful, jpg is a lossy compression format, while png is lossless, the disadvantage is that it is quite large. In order to reduce the image size and achieve the fastest download speed, each picture should be optimized before uploading. Yslow that focuses on the front end has a tool called smushit
Http://www.smushit.com/ysmush.it/
This tool is a lossless compression tool that optimizes the volume of your images while maintaining their original quality. This optimization volume is usually more than 10%. Which means
A picture of 30KB is optimized with only 27KB or less.
Thank you for reading this article carefully. I hope the article "how to improve the speed of website access" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.