Font loading in Ruby on Rails project takes too long

I participate in a Rails project and I use two fonts that are in the folder /assets/fonts.

@font-face {
  font-family: FuturaStd-Light;
  src: url("/assets/fonts/FuturaStd-Light.otf");
}

@font-face {
  font-family: HelveticaNeue;
  src: url("/assets/fonts//HelveticaNeue.dfont");
}

Fonts are very large files (especially the second one), and it downloads them forever. And on each page, the text appears after everything else.

Is there a better way to download fonts? Is there any way to cache them? Any ideas?

+5
source share
2 answers

@ font-face is a great technique, but large font files will certainly slow down your site. There are many methods you can use to combat this:

, , IE , SCRIPT. , javascript, .

:

+3

, @font-face , google, typekit - . , , Google. , , - - . Html.erb:

<link href='http://fonts.googleapis.com/css?family=PT+Sans:400,700,400italic' rel='stylesheet' type='text/css'> 

css:

h1 {
  font-family: "PT Sans", Arial, Helvetica, sans-serif;
}
+1

All Articles