CSS

When to use link or @import?

DIFFERENCE:

Loading Order:

1.Link adds css file first and then compile, while @import will wait until html structure loaded which might influence visual effect.

2.Link parallel downloads css files while @import downloads one by one

DOM Supportability:

when using DOM changing styles, linked css is OK but imported doesn’t work.

Restriction:

Link can link JS file and so on but @import could only import css file.

 

WHEN TO USE:

  link: In general condition, link is recommended.

  @import: In a  large website, too many pages linking to the same css file might cause delay. Use @import flexibly can improve the css modularity.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s