Dequeuing Font Awesome
-
Hello,
I have problem with font loading 2 times. I use the following in functions.php:
// Remove and unregister old font Awesome. function remove_styles(){ wp_dequeue_style('layers-font-awesome'); wp_deregister_style('layers-font-awesome'); wp_dequeue_style('font-awesome'); wp_deregister_style('font-awesome'); } add_action( 'wp_head', 'remove_styles', 999); // Add new font Awesome. function load_awesome() { wp_enqueue_style('font-awesome', '//use.fontawesome.com/releases/v5.8.1/css/all.css'); } add_action( 'wp_enqueue_scripts', 'load_awesome', 999);
When I look at GTMetrix, first the following file is downloaded:
https://use.fontawesome.com/releases/v5.8.1/css/all.css
Then:
https://use.fontawesome.com/releases/v5.8.1/webfonts/fa-solid-900.woff2Unfortunately also this one loads from my FTP server, duplicating the latter:
…/themes/storefront/assets/fonts/fa-solid-900.woff2How can I prevent it from being used? It loads much longer than the one from use.fontawesome.com and I don’t want extra bloat.
Changing 999 to 1 results in FTP font from Storefront theme being used instead, but still both files are requested:
add_action( 'wp_enqueue_scripts', 'load_awesome', 1);
The page I need help with: [log in to see the link]
- The topic ‘Dequeuing Font Awesome’ is closed to new replies.