CSS optimization skills self-practice experience

CSS optimization skills self-practice experience
1. Use css sprites.

The advantage is that the small images used in CSS can be merged into one large image, which reduces the requests to the server, reduces the server pressure, and speeds up page loading.

2. Merge multiple css files into a single css file.

Same benefits as css sprites

3. Use external CSS.

External CSS can be cached by browsers and is easy to maintain.

4. Put the css in the head.

You can refer to Yahoo's document http://developer.yahoo.com/performance/rules.html#css_top

5. Use link instead of import

Using import will slow down page loading. Moreover, the loading order in IE may be inconsistent with expectations, which will directly lead to display problems.

6. Use CSS abbreviations.

For example, use margin instead of margin-top.

7. Put similar styles together to avoid repetitive writing.

8. Reduce line breaks.

9. Delete the final semicolon.

10. Use single-line comments.

11. RGB color abbreviation.

12. Remove unnecessary units, such as px.

13. Delete unused styles.

It can reduce file size and shorten browser parsing and matching time.

14. Compress CSS files.

All of the above are very simple and there is no need to explain them in detail. Of course, some CSS compression tools have optimization functions.

<<:  A guide to writing flexible, stable, high-quality HTML and CSS code standards

>>:  WeChat applet implements search function and jumps to search results page

Recommend

Detailed explanation of Vue two-way binding

Table of contents 1. Two-way binding 2. Will the ...

Detailed explanation of mktemp, a basic Linux command

mktemp Create temporary files or directories in a...

Solution to Docker image downloading too slowly

Docker image download is stuck or too slow I sear...

Detailed explanation of how to find the location of the nginx configuration file

How can you find the location of the configuratio...

A brief discussion on the principle of React two-way data binding

Table of contents What is two-way data binding Im...

Tutorial analysis of quick installation of mysql5.7 based on centos7

one. wget https://dev.mysql.com/get/mysql57-commu...

Windows Service 2016 Datacenter\Stand\Embedded Activation Method (2021)

Run cmd with administrator privileges slmgr /ipk ...

Vue implements simple image switching effect

This article example shares the specific code of ...

SQL-based query statements

Table of contents 1. Basic SELECT statement 1. Qu...

Summary of the use of element's form elements

There are many form elements. Here is a brief sum...

In-depth analysis of the diff algorithm in React

Understanding of diff algorithm in React diff alg...

Simple tutorial on using Navicat For MySQL

recommend: Navicat for MySQL 15 Registration and ...

Detailed explanation of common usage methods of weixin-js-sdk in vue

Link: https://qydev.weixin.qq.com/wiki/index.php?...

jQuery implements article collapse and expansion functions

This article example shares the specific code of ...