N
N
Norval2016-12-28 22:43:49
css
Norval, 2016-12-28 22:43:49

Why is the @import method bad?

I heard in various sources that "import is not ok" and it is undesirable to use it.
And then I finally found a mention in David McFarland's book about CSS:
"The import method can have a small impact on the performance of your sites (that is,
slightly reduce the speed of their work)."
But it's not clear yet. But why? Why? AS? If so and so the content needs to be loaded. That is, from html-pages, the link goes to fonts, if we assume, then there is a load. And if through import - too, after all, the loading is in progress. What's the point then? Mystery.
It would seem, well, it's cool when there is only 1 css file that all HTML pages refer to, and it is already supplemented EASILY with links to other CSS files. That is, it is not clear what can go wrong)
Addition:
The most important question at the moment is when a font is referenced from an HTML file (from Google Fonts for example) and when the font is included in the CSS file, i.e. We consider 2 cases if - whether the import is bad.
If I understood the words sim3x (and @dpr) correctly, then when a document refers to a style sheet, and it imports to another style sheet, then this is ... well, just 1 more request, after all, which is probably not critical? Well, is it the same with fonts?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
sim3x, 2016-12-28
@Norval

Browsers can load resources in multiple threads
If you write imports in a css file, they will start loading later

I
iBird Rose, 2016-12-28
@iiiBird

https://habrahabr.ru/post/57012/
ps if you like import so much, then use preprocessors. almost the same imports, but the output is a beautiful one file, and also minified, if you want.

A
A person from Kazakhstan, 2016-12-29
@LenovoId

For the test: create a folder with a standard structure on the desktop, CSS J's IMG folders and an index file, two CSS files in the CSS folder, connect one via link and the second via import to the CSS file and you will see that it will take longer to load, for example 8-10sec

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question