Okay
  Public Ticket #2145725
About Preload
Closed

Comments

  •  8
    ynskdemir started the conversation

    Hi, I want to preload this asset. Because it causes speed problem. Can you help?

  • [deleted] replied

    Hi,

    The font is included in:

    assets/js/slick/slick-theme.css:16

    So the code to preload the font file is this:

    add_action( 'wp_head', function() {
        printf( '<link rel="preload" href="%s" as="font">', esc_attr( get_template_directory_uri() . '/assets/js/slick/fonts/slick.woff' ) );
    }, 1 );
    

  •  8
    ynskdemir replied

    If I place this code am I able to preload it? 

    Where should I place this code?

  • [deleted] replied

    Hi,

    The code should be added in functions.php (end of file). I have modified to fix few missing attributes:

    add_action( 'wp_head', function() {
        printf( '<link rel="preload" href="%s" as="font" type="font/woff" crossorigin>', esc_attr( get_template_directory_uri() . '/assets/js/slick/fonts/slick.woff' ) );
    }, 1 );

    The browser will preload it automatically based on your question this is how preloading font works.

  •  8
    ynskdemir replied

    Thank you a lot :) It was very helpful