Code for performance optimization optimizes page loading speed

  • 2021-07-24 10:13:21
  • OfStack

The optimization of page code also has a great impact on page loading speed. The most well-known ones are:

JavaScript in the HTML header and Style written in the HTML tab will block the rendering of the page, so CSS is placed at the head of the page and introduced using Link, and JavaScript is introduced at the end of the page.

Secondly, there are:

1. Load on demand, and load JS such as statistics and sharing after the page onload, which can improve the access speed;

2. Optimize Cookie and reduce the volume of Cookie;

3. Avoid empty src of [] ();

4. Try to avoid setting the picture size. Resetting the picture size many times will cause multiple redrawings of the picture and affect the performance;

5. Reasonable use of display attributes:

display: width, height, margin, padding and float should not be used after inline display: float should not be used after inline-block display: vertical-align should not be used after block display: margin or float should not be used after table-*

6. Do not abuse Float and Web fonts;

7. Try to use CSS3 animation;

8. Load partial requests asynchronously using AJAX;


Related articles: