Website front-end performance optimization tutorial and front-end performance optimization tutorial

Source: Internet
Author: User

Website front-end performance optimization tutorial and front-end performance optimization tutorial



A series of previous blog posts introduced the database performance optimization on the website background. In fact, the front-end optimization is also very important. When the speed of the database model documents increases, page loading is still slow. At this time, you need to optimize the front-end code of the website.

 

There are not many tutorials on front-end performance optimization. I finally found a textbook, "high-performance website construction Guide". The following describes how to optimize the front-end performance based on the content of this book.

 


 

1. Reduce http requests

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

Only one request is allowed.

 

1. Use an image map

We know that an img tag will send a request to the server to retrieve images. If multiple images are merged into one image, multiple requests can be converted into one request. This is the image map.

The image map corresponds to different events based on the locations clicked by the user, which makes the front-end code more complex and difficult to understand. I personally think it is not feasible.

 

 

2. Merge JavaScript and Css files

A script tag or link tag also initiates a request to the server. Therefore, you must reduce the number of times that external files are referenced on the page. Generally, a page is configured with a JS and a CSS.

 

3. Avoid redirection

Redirection also sends an Http request.

 

Ii. Use the content publishing network

The system automatically selects the server closest to the user.

 

Iii. Use Cache

1. Specify the Expire Header

Use Expire to specify cache 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.

 

Iv. Compression Components

Streamline the code. It has Js Code.

The main methods are to delete spaces and replace long variable names with v_1 and v_2.

Tool: gzip

 

5. Place the CSS file on the top

In this way, the page is loaded and displayed gradually, enhancing the user experience and preventing white screens.

 

6. Place the JavaScript file at the bottom

Prevent page display from being blocked by the download script.

 

 

JavDroider's Blog welcomes criticism and suggestions ~~

 

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.