Support » Plugin: Code Snippets » link rel Preload Fonts in head

Viewing 4 replies - 1 through 4 (of 4 total)
  • 75tiagomatias

    (@75tiagomatias)

    Hello, I am posting just to say that I have the exact same problem.

    Already tested put in Header the code:

    <link rel=”preload” href=”fonts/houzez-iconfont.ttf?jd28ud” as=”font” type=”font/ttf” crossorigin=”anonymous”>

    and it didn’t work.

    I’ll be watching this post to see if there are any developments.

    Regards,
    Tiago Matias

    Plugin Author Shea Bunge

    (@bungeshea)

    Hi @woodprop and @75tiagomatias,

    You can add this code to your site by wrapping it in a wp_head action:

    add_action( 'wp_head', function () {
    	$fonts_dir = get_template_directory_uri() . '/fonts/';
    	?>
    
    <link rel="preload" href="<?php echo get_template_directory_uri(); ?>/fonts/houzez-iconfont.ttf?jd28ud" as="font" type="font/ttf" crossorigin>
    <link rel="preload" href="<?php echo plugins_url( '/assets/lib/eicons/fonts/eicons.woff2?5.9.1' ); ?>" as="font" type="font/woff2" crossorigin>
    
    <?php } );
    SamBruton

    (@sambruton)

    How can we edit those head <link> tags that have been added by default either by WordPress or by plugins/themes?
    I’m finding it different because the code is PHP wordpress markup which makes it difficult to add the ‘rel=preload’ attribute to link tags.

    Any suggestions? I’m using xstore for my custom theme.

    Plugin Author Shea Bunge

    (@bungeshea)

    Unfortunately, I don’t have a copy of the xstore theme, and so I can’t say for sure if there’s some mechanism for replacing scripts. It’s not something I can provide a general solution for.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘link rel Preload Fonts in head’ is closed to new replies.