Topbar Left

+1 (800) 555-0100

Email Address

contact@example.com

hamiltonpouchar
  • Home
  • About
  • Services
  • Blog
  • Contact

How to Avoid CSS@import? What is it and Why is Required?

Array

How to Avoid CSS@import? What is it and Why is Required?

Posted by Gurjeet, 3rd June 2023
How to avoid CSS@import? What is it and Why is Required-oxo-solution-digital-marketing-sompany

Cascading style sheets (CSS) is a style sheet language which is used to describe the look and formatting of the web page. 

What is CSS@import?

It is a process of importing CSS file into another CSS file. It is an external stylesheet. Here is the example of CSS@import.

<style>

@import url(B.css) ;

</style>

Why avoid CSS@import?

It causes additional HTTP requests for server and browser which increases the page load time. 

The delay in page load occurs because the files are downloaded in a sequential manner (this means one after the other) instead of downloading parallelly. The sequential loading adds additional round trip times to the overall page and thus slows down the web page as per the number of CSS files imported. 

Positions of CSS@import?

CSS @ import can be added in both CSS files and HTML pages. 

  • Usage in CSS files
    • It can be located at the top of the page. Here is the example of the script:
@import url(“style2.css”)

  • Usage in HTML files
    • It is used in the style tags. Here is an example:
<style type=”text/css”>

@import url(“style2.css”);

font-family: sans serif;

font-size: 17px;

font-weight: 300;

# more CSS scripts #

</style>

You may also like to read:- How You Can Make Money with eCommerce Website


How to avoid CSS@import?

This problem can be fixed using one of three methods:

#Method 1: By combining CSS files

 One method is that you can merge the files. This means you can simply copy and paste the files you were importing, directly into the original file. This will remove the need to import the file. 

Another way is that you can add a separate link in the header of HTML instead of adding CSS@import. 

#Method 2: By using inline CSS in HTML

If the CSS is inlined in the HTML, this reduces the unnecessary sequential loading of the page. 

<img src="picture.jpg" /><script type=“text/css”>…CSS script goes here…</script>

#Method 3: By using link tag in the HTML

If the link tag is used in the header of HTML instead of using CSS@import, this also helps in reducing the problem. 

<link href=”style2.css” rel=” stylesheet” type=”text/css”>

Conclusion

This article explains why CSS@import is bad for the page speed, including the additional steps that are added for the browser to load the web page. Moreover, it causes the browser to download, parse and then go out and get the next CSS file before it starts displaying the page.  

The best practice is to use not even a single @import.

Post navigation

Next

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

Recent Posts

  • Modafinil: A Chave Para Realizar Todo O Seu Potencial
  • Modafinil-Fordele: Realisering Af Dit Potentiale
  • Kracht Van Provigil En Zijn Voordelen
  • Vorteile Der Einnahme Von Modafinil
  • Οφέλη της Μοδαφινίλης: Ξεκλειδώστε το πλήρες δυναμικό σας.

Categories

  • eCOmmerce (1)
  • Search Engine Optimization (3)
  • Server Security (1)
  • Social Media (1)
  • Uncategorized (95)
  • Web Design (17)
  • Web Developer (13)
  • Website Health (21)
  • Website Hosting (1)
  • Website Speed (1)

About

We are committed to delivering cutting-edge solutions to clientele around the globe. We believe that innovation and creativity are the heart and soul of the organization. Our approach is entirely client-centric as we are engaging customers, solving business challenges, and giving novel business ideas.

We are on Social Media

  • youtube
  • twitter
  • instagram
  • linkedin
  • facebook

Pages

  • Blog
  • About
  • Services
  • Contact

Contact Number

+1 (800) 555-0100

Address

1800 Amphibious Blvd.
Mountain View, CA 94045

Email Address

contact@example.com

©2025 hamiltonpouchar. All rights reserved.

Designed by OXO Solutions®