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

WordPress

Ahmed Hassan
Ahmed Hassan
5,533 Points

@import Google Fonts

Why did Zac cut the "@import" from the style.css file and pasted it in the functions.php?.. I mean he already enqueued the entire style.css file into functions.php, and when WP load style.css, it will automatically run get Google Fonts because it's already been imported within the style.css!

3 Answers

Maybe for performance benefits. This article suggests that using the @import method blocks the loading of the page until loading the font files is complete: http://www.wpbeginner.com/wp-themes/how-add-google-web-fonts-wordpress-themes/

Kevin Korte
Kevin Korte
28,148 Points

Wheres the link to the video? My hunch is that following Google's advice of using the @import is not a very good solution, and there are better ways to bring in google fonts, and maybe that's what Zac was trying to do.

Although the performance hit of @importing google font's is small, it is a blocking, and it should be avoided if possible.

Ahmed Hassan
Ahmed Hassan
5,533 Points

Yes Ryan.. Thanks for your answer, it helped.