Website Foreground performance Optimization Tutorial

Source: Internet
Author: User



Before a series of blog post introduced the database performance optimization, in fact, the front-end optimization is also very important. When the database fan speed up, there will still be slow page loading phenomenon, at this time, the site needs to optimize the front-end code.

About the front-end performance optimization of the tutorial is not much, finally found a textbook, "high-performance Web site Construction Guide," below to the content of this book as the main line, explain the front-end performance optimization method.


one, reduce the HTTP request

This is an important principle for improving front-end performance.

One less request can be a single time.

1. Use the image map

We know that an IMG tag will initiate a request for a picture to the server, so if you combine multiple images into one image, you can turn multiple requests into a single request, which is the image map.

Image map through the user click the location of different and corresponding events, this will make the foreground code becomes more complex, difficult to understand, personally feel not feasible.

2. Merging JavaScript and CSS files

A script tag or link tag also initiates a request to the server, so you must reduce the number of times the page references an external file. In general, a page with a JS and a CSS.

3. Avoid redirects

Redirects also issue HTTP requests.

Ii. use of the content publishing network

The system will automatically pick the server closest to the user.

third, using the cache

1. Specify the expire header

Using expire to specify the use of caching for components

You can also use cache-control:max-age=315360000 instead

2. Use external JS and CSS files

Built-in JS and CSS are usually not cached.

Four, compression components

Streamline your code. There is the JS code

The main method is to delete the space, the longer variable name with V_1, v_2 and the like instead

Tool: gzip

put the CSS file on top

This allows the page to gradually load the rendering, enhance the user experience, and prevent white screen.

VI. Place JavaScript files at the bottom

Prevents the download script from blocking the page display.

Javdroider ' s Blog welcomes criticism suggestions ~ ~

Website Foreground performance Optimization Tutorial

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.