Local Font Preload Issue
-
I locally installed font “IBM PLex Sans” and used the following CSS in Appearance: Customize: Additional CSS section in GP.
@font-face {
font-display: swap; font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 400; src: url('https://mywebsite.com/wp-content/uploads/.../ibm-plex-sans-v19-latin-regular.woff2') format('woff2');
font-display: swap; font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 400; src: url('https://mywebsite.com/wp-content/uploads/.../ibm-plex-sans-v19-latin-300.woff2') format('woff2');
font-display: swap; font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 400; src: url('https://mywebsite.com/wp-content/uploads/.../ibm-plex-sans-v19-latin-500.woff2') format('woff2');
}When i open the home page, first some default font loads and after a fraction of second, locally installed IBM Plex Sans loads. To counter that, I researched the GP forums and found the following snippet that I added to my site:
add_action( 'wp_head', function(){
echo '<link rel="preload" as="font" type="font/woff2" href="https://mywebsite.com/wp-content/uploads/....../ibm-plex-sans-v19-latin-300.woff2" crossorigin="anonymous">
<link rel="preload" as="font" type="font/woff2" href="https://mywebsite.com/wp-content/uploads/....../ibm-plex-sans-v19-latin-regular.woff2" crossorigin="anonymous">
<link rel="preload" as="font" type="font/woff2" href="https://mywebsite.com/wp-content/uploads/...../ibm-plex-sans-v19-latin-500.woff2" crossorigin="anonymous">';
} );But this is not working and font is displayed only after a default font is displayed first. As this was not working, I changed the OMGF plugin’s display option from “swap” to “auto”.
Note: I am using the OMGF plugin to block some other Google font that I do not need.
What can be done to load my local font immediately?
The topic ‘Local Font Preload Issue’ is closed to new replies.
