$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>functions - Remove Font-Awesome MaxCDN Link & Load Locally|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

functions - Remove Font-Awesome MaxCDN Link & Load Locally

matteradmin8PV0评论

MaxCDN is slowing down my site so I want to load font-awesome locally but I can't seem to write the correct function to remove it.

function remove_unwanted_css(){
wp_dequeue_style(‘font-awesome’, ‘.7.0/css/font-awesome.min.css’);
}
add_filter(‘wp_print_styles’, ‘remove_unwanted_css’);

MaxCDN is slowing down my site so I want to load font-awesome locally but I can't seem to write the correct function to remove it.

function remove_unwanted_css(){
wp_dequeue_style(‘font-awesome’, ‘https://maxcdn.bootstrapcdn/font-awesome/4.7.0/css/font-awesome.min.css’);
}
add_filter(‘wp_print_styles’, ‘remove_unwanted_css’);
Share Improve this question asked Jan 11, 2019 at 11:51 squidgsquidg 1275 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

You must find the name of the enqueued stylesheet in your theme and use it to dequeue a style - wp_dequeue_style. URL is unnecessary.

Example:

function remove_unwanted_css() {
   wp_dequeue_style( 'font-awesome' );
}
add_action( 'wp_print_styles', 'remove_unwanted_css', 100 );

Or another solution wp_deregister_style/:

add_action( 'wp_enqueue_scripts', 'remove_default_stylesheet', 20 );
function remove_default_stylesheet() {
    wp_dequeue_style( 'font-awesome' );
    wp_deregister_style( 'font-awesome' );

    wp_register_style( 'new-font-awesome', get_stylesheet_directory_uri() . '/new.css', false, '1.0.0' ); 
    wp_enqueue_style( 'new-font-awesome' );
}
Post a comment

comment list (0)

  1. No comments so far