This question relates to situations where a web font is not required on the main page and is initially inside a div set to display:none;
I have a webpage that loads a hidden form through Javascript on click, and this form uses a web font. My problem is that there is one second delay when the user clicks to open the form, since at that moment Chrome is loading the woff2 file.
This is not very pleasant for the user.
I need to preload webfont since I donβt have to use the font on the main page, so there is nothing to get Chrome to get the woff2 file before users click to open the hidden form.
I noticed that it doesnβt matter if you host Font Awesome on your server or use a CDN.
I looked on the Internet to see what can be done, I tried everything below, and none of this helped, nothing caused the woff2 file to load to load the page, it only ever loaded when the web page actively needs a font.
Attempt 1: Preload
<link rel="preload" href="form/font-awesome-4.5.0/fonts/fontawesome-webfont.woff2">
or
<link rel="preload" href="form/font-awesome-4.5.0/fonts/fontawesome-webfont.woff2" as="font">
Attempt 2: Prefetch
<link rel="prefetch" href="form/font-awesome-4.5.0/fonts/fontawesome-webfont.woff2">
Attempt 3: CSS
@font-face { font-family: 'Font-Awesome'; src: url('form/font-awesome-4.5.0/fonts/fontawesome-webfont.woff2') format("woff2");; }
As I looked around, I began to see possible solutions with Javascript-based loading, something that I really didnβt want to bring closer, so what are my options?
source share