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

How to apply TypeScript classes in Vue projects

Table of contents 1. Introduction 2. Use 1. @Comp...

Implementation of element multiple form validation

In the project, form testing is often encountered...

Detailed steps for installing Tomcat, MySQL and Redis with Docker

Table of contents Install Tomcat with Docker Use ...

Zookeeper stand-alone environment and cluster environment construction

1. Single machine environment construction# 1.1 D...

Vue scaffolding learning project creation method

1. What is scaffolding? 1. Vue CLI Vue CLI is a c...

Solution to mysql prompt "got timeout reading communication packets"

Error message: user: 'root' host: `localh...

MYSQL master-slave replication knowledge points summary

An optimization solution when a single MYSQL serv...

CSS3 gradient background compatibility issues

When we make a gradient background color, we will...

A colorful cat under Linux

Friends who have used the Linux system must have ...

Ubuntu boot auto-start service settings

How to create a service and auto-start it in Ubun...

Tutorial on installing MySQL8 compressed package version on Win10

1 Download MySQL8 from the official website and i...

Detailed tutorial for installing ElasticSearch:7.8.0 cluster with docker

ElasticSearch cluster supports動態請求的方式and靜態配置文件to ...