Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

WooCommerce star.woff font slows down my site’s loading and suggests that I use

$
0
0

Replies: 0

Google PageSpeed ​​Insights tells me that the WooCommerce star.woff font slows down my site’s loading and suggests that I use the <link rel = preload> tag to save approximately 2.35 seconds. Can someone show me how I can fix this? I read a bunch of articles, tried a bunch of codes, it didn’t help.

function my_queue_items() {
wp_enqueue_style( ‘rating-stars’, ‘/wp-content/plugins/woocommerce/assets/fonts/star.woff’ );
wp_script_add_data( ‘rating-star’, ‘crossorigin’, ‘anonymous’ ); // Adds Crossorigin Attribute
}
add_action( ‘wp_enqueue_scripts’, ‘my_queue_items’, 99 );

// Enqueue Your Font
function my_queue_items() {
wp_enqueue_style( ‘rating-stars’, ‘/wp-content/plugins/woocommerce/assets/fonts/star.woff’, array(), null );
}
add_action( ‘wp_enqueue_scripts’, ‘my_queue_items’, 99 );

// Add Crossorigin Attribute To Your Font
function style_attributes( $html, $handle ) {
if ( ‘rating-stars’ === $handle ) {
return str_replace( “media=’all'”, “media=’all’ crossorigin=’anonymous'”, $html );
}
return $html;
}
add_filter( ‘style_loader_tag’, ‘style_attributes’, 10, 2 );

<link rel=”preload” href=”Font URL Showing in PageSpeed” as=”font” crossorigin=”anonymous”>

No result!!!!!


Viewing all articles
Browse latest Browse all 59525

Trending Articles