Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS Modular CSS with Sass Getting Modular with Mixins and Functions Pixels to Em Function

Anwar Rizalman
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Anwar Rizalman
Python Development Techdegree Graduate 33,620 Points

Regarding @import for font style

I have always been using the <link> element tag in the html when I use the google font. But since I have started doing these SASS courses I have seen the google font link being declared or written in the SASS file instead.

Is one of this way better than the other?

2 Answers

Flor Antara
Flor Antara
12,372 Points

Hi Anwar,

The difference is in performance.

When you load your fonts with @import, the browser has to go and fetch that resource, and until it's done, it won't continue parsing the CSS that's below that @import rule. It's render blocking.

When you <link> fonts (or any other CSS file), they will be added to the parallel download queue, meaning that the browser will be processing them at the same time. Helping the webpage load faster.

Flor Antara
Flor Antara
12,372 Points

Exactly.

I would say <link> is the most used one.

It's definitely the one I pick.