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.com/font-awesome/4.7.0/css/font-awesome.min.css’);
add_filter(‘wp_print_styles’, ‘remove_unwanted_css’);

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.


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' );

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.