Does @import ads use bad practice?

Possible duplicate:
Difference between @import and link in CSS

I read about CSS @import as bad practice and wondered about the methods that I use.

I am currently creating a website using WordPress that imports each plugin stylesheet via link links, and the main stylesheet is linked in the same way, however the main stylesheet currently contains several @import , which I believe must be moved to the title or to the corresponding pages on which they are used (two of them are used only on certain pages).

Are my problems justified and what are the consequences of using these @import ads?

+6
source share
4 answers

I think you should use LINK for simplicity - you must remember to put @import at the beginning of the style block, otherwise it will not work. It turns out that avoiding @import is better for performance.

link

  • Linking is the first way to include an external style sheet in your web pages. It is designed to link your web page to your stylesheet.

import

  • Import allows you to import one style sheet into another. This is slightly different from the link script, as you can import style sheets inside the linked style sheet.

The most common reason for using @import is that older browsers did not recognize @import, so you could hide styles from them.

This link solves all your requests.

What is the difference between @import and a link for CSS?

+3
source

The Internet contains a lot of information about this topic, I suggest reading:

+4
source

Using the import rule is not a bad practice in itself. You just have to keep in mind that the import is only processed after the file containing them has been loaded. Therefore, if you have a bunch of files with these statements, it may take quite a while for your audience to see that css is being applied.

Each @import creates a new HTTP request, as it occurs on the client side. Thus, from this point of view, you will damage visitors with slow connections, such as mobile visitors on Edge or 3G.

Thumb Rule I've heard a lot about combining all the CSS you need instantly and using @import for the things you need later.

+2
source

It's better NOT to use @import to enable CSS on the page for speed reasons.

import allows you to import one style sheet into another. This is slightly different from the link script, as you can import style sheets inside the linked style sheet. Old browsers did not recognize @import , so you can hide styles from them, this is the reason for @import .

check this:
http://www.stevesouders.com/blog/2009/04/09/dont-use-import/
css @import

+1
source

Source: https://habr.com/ru/post/921601/


All Articles