Reason: When the browser opens a webpage, it needs to download the data in the webpage back to the local computer and then display it; if there is more content in the webpage, the number of link requests will be more, and the slower the webpage will be opened. . Compressing CSS files can reduce the number of bytes occupied by CSS code, reduce file size, network transmission volume and bandwidth usage, thereby increasing page opening speed.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
When the browser opens a webpage, it needs to download the data in the webpage back to the local computer and then display it.
The downloaded web page content includes: images, text, program codes in the web page: CSS, HTML, js scripts, fonts, etc., the number is up to hundreds.
When the browser opens a web page, it also requests the server to download the content in the web page. If the amount of content in the web page is larger, the number of link requests will be more; if the content is larger, the download time after the link will be longer.
Therefore, reducing the number of links and content size is an important way to improve the speed of opening web pages. So we usually have to compress css files.
Benefits of compressing css files:
1. Reduce file size
2. Reduce network transmission volume and bandwidth usage
3. Reduce the processing pressure on the server
4. Improve the rendering and display speed of the page
Where to start with CSS code compression
After the web page is developed, the CSS code to be published to the website can be directly reduced and compressed, such as removing spaces, line breaks, redundant semicolons, etc.
Of course, some CSS codes can be optimized. Significantly reduces the amount of code and therefore file size.
Learning video sharing: css video tutorial
The above is the detailed content of Why is css compressed?. For more information, please follow other related articles on the PHP Chinese website!