TechVigil Logo

Import Multiple Google Web-fonts in a Single Request

uncategorized

Many designers are now widely using web fonts to decorate their pages and quite a few of them use Google Web Fonts specifically. But embedding too many web fonts in a page increase number of request for each of them. This can increase page load time. So, what should be the solution?

Multiple Import in One Request

Tu reduce number of request to Google font API, we can combine all of them in a single tag. Consider this example. Suppose we have to import two fonts, 'Brawler' and 'Righteous'. Normally users put two different tags for each one, like:

This code can be optimized and can be written as:

Here we are combining multiple requests into a single tag, just separating the fonts with a pipe "|" character. This trick seems very simple but improve your page loading, specially for old browsers which only have 2 connections open per domain at a time.

The JavaScript Version

If you are using JavaScript for applying Web fonts to your pages, you may use this code for multiple font request:

What to Avoid

Using @import directives in CSS for embedding web-fonts may seems flexible and comfortable for you. But, it is strictly advised not to use @import in CSS to import any font.

@import url(http://fonts.googleapis.com/css?family=Brawler|Righteous);

This directive is not well processed by older versions of Internet Explorer and may raise some performance issue.

Sandeep Kumar

Sandeep Kumar

Founder & Editor-in-Chief | Software Architecture & System Design

About Sandeep →

Electronics engineer and tech enthusiast specializing in software architecture, system design, and building scalable tech solutions. Passionate about sharing real-world engineering experiences, practical lessons, and tech insights.