Home  >  Article  >  Web Front-end  >  Why is it not recommended to use @import to introduce css?

Why is it not recommended to use @import to introduce css?

王林
王林forward
2020-06-13 16:14:562782browse

Why is it not recommended to use @import to introduce css?

It is not recommended to use @import for the following two reasons:

Reason 1. Using @import to introduce CSS will affect the browser’s parallel download

The CSS file referenced using @import will only know that there is another css that needs to be downloaded after the css file that references it is downloaded and parsed. Then it will be downloaded, and then after downloading Start a series of operations such as parsing and building render tree. This results in the browser being unable to download the required style files in parallel.

Reason 2: Multiple @imports will cause the download order to be disordered.

In IE, @import will cause the download order of resource files to be disrupted, that is, the js files listed behind @import are downloaded before @import, and disrupt or even destroy @import itself. Parallel downloads.

We can use the link tag to introduce css.

Recommended tutorial: css quick start

The above is the detailed content of Why is it not recommended to use @import to introduce css?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:juejin.im. If there is any infringement, please contact admin@php.cn delete