Can someone explain what are the benefits of using the @import syntax comparing to just including css using the standard link method?
Goods and services are likely to be imported from abroad for several reasons. Imports may be cheaper, or of better quality. They may also be more easily available or simply more appealing than locally produced goods. In many instances, no local alternatives exist, and importing is essential.
Exports are goods that are sold in a foreign market, while imports are foreign goods that are purchased in a domestic market. Exports and imports are important for the development and growth of national economies because not all countries have the resources and skills required to produce certain goods and services.
As the answerer said, it lets you split your CSS into multiple files whilst only linking to one in the browser.
That said, it's still wasteful to have multiple CSS files downloading on high-traffic websites. Our build script actually "compiles" our CSS when building in release mode by doing the following:
@import
statements; during compilation, each of these is replaced by the minified CSS of that fileThus we end up with a single, minified CSS file in production, whilst in development mode we have the separate files to make debugging easier.
If you use <link>
s in your HTML files, all those files have to keep track of all the CSS files. This obviously makes changes and additions (both for CSS and HTML files) harder.
Using @import
, you reduce a theoretically infinite number of changes down to one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With