23tux 23tux - 1 year ago 101
HTML Question

Page view calls for hosted fonts

A lot of commercial font sites like myfonts.com do page view tracking with CSS like this:

@import url("//hello.myfonts.net/count/123456");

When I look into Chromes network tab, I see that the call to this URL takes about 100-250ms (depending if https or http). This seems a lot to me, because it happens on every CSS parsing.

I'm wondering if this calls have some negative performance issues when loading a site? (blocked loading or rendering of CSS, timeouts when the URL is not accessible or a poor internet connection on mobile...)

I'm not too deep into chromes performance tools, but I think that there must be a way to analyze if this call blocks something when loading a page.

Answer Source

I figured it out by myself. I used this code

@import url(http://localhost/wait.php)

// wait.php

And the browser waits indeed the 10 seconds before rendering the page. It loads other requests to JS files... asynchron, but the rendering is blocked.

There would be two possible solutions

  • Don't use any commercial fonts (we are going to replace our commercial fonts with open source / free fonts)
  • Or: Put the page view code on the bottom of the page


    @import url("//hello.myfonts.net/count/123456");

This way the browser can render the content and when it's nearly done, it fires the page view count for your commercial fonts.

Btw: Depending on http / https and your location it takes about 50-300ms to fire this page view counts.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download