• Resolved danielmoorehbd

    (@danielmoorehbd)


    Hi,
    I have spent a lot of time trying to minify CSS & JS on the back of WordPress with no joy.
    Also, there are many plugin/theme styles and scripts there that I can’t get rid of, this code doesn’t seem to work:

    function remove_cssjs_ver( $src ) {
    if( strpos( $src, '?ver=' ) )
     $src = remove_query_arg( 'ver', $src );
    return $src;
    }
    add_filter( 'style_loader_src', 'remove_cssjs_ver', 10, 2 );
    add_filter( 'script_loader_src', 'remove_cssjs_ver', 10, 2 );
    
    remove_action( 'wp_head', 'rsd_link' ) ;
    
    remove_action('wp_head', 'print_emoji_detection_script', 7);
    remove_action('wp_print_styles', 'print_emoji_styles');
    remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
    remove_action( 'admin_print_styles', 'print_emoji_styles' );
    
    remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0);
    
    function disable_embed(){
    wp_dequeue_script( 'wp-embed' );
    }
    add_action( 'wp_footer', 'disable_embed' );
    
    add_filter('xmlrpc_enabled', '__return_false');
    
    remove_action( 'wp_head', 'wp_generator' ) ;
    
    remove_action( 'wp_head', 'wlwmanifest_link' ) ;
    
    function deregister_qjuery() { 
     if ( !is_admin() ) {
     wp_deregister_script('jquery');
     }
    } 
    add_action('wp_enqueue_scripts', 'deregister_qjuery');
    
    function disable_pingback( &$links ) {
     foreach ( $links as $l => $link )
     if ( 0 === strpos( $link, get_option( 'home' ) ) )
     unset($links[$l]);
    }
    add_action( 'pre_ping', 'disable_pingback' );
    
    add_action( 'init', 'stop_heartbeat', 1 );
    function stop_heartbeat() {
    wp_deregister_script('heartbeat');
    }
    
    add_filter( 'wpcf7_load_js', '__return_false' );
    add_filter( 'wpcf7_load_css', '__return_false' );
    
    function speedupadmin() { 
     if ( !is_admin() ) {
      wp_deregister_style('wp-admin');
      wp_deregister_style('fvp-backend');
      wp_deregister_style('cwginstock_admin_css'); //Back In Stock Notifier
      wp_deregister_style('wpmtst-admin-global-style'); //Strong Testimonials
      wp_deregister_style('trustpilotSideLogoStylesheet'); //Trustilot
      wp_deregister_style('wc-aelia-foundation-classes-admin'); //Aelia
     // wp_deregister_style('storefront-plugin-install') //Storefront Installer
      wp_deregister_style('arconix-faq-admin'); //Acronix FAQ
     }
    } 
    add_action('admin_enqueue_scripts', 'speedupadmin');
    
    if ( !is_admin() ) {
      remove_action('wp_enqueue_styles', 'wp_enqueue_styles');
    }
    
    remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); 
    remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); 
    remove_action( 'wp_print_styles', 'print_emoji_styles' ); 
    remove_action( 'admin_print_styles', 'print_emoji_styles' );
    
    add_action( 'admin_enqueue_scripts', 'admin_enqueue_scripts' );
Viewing 13 replies - 1 through 13 (of 13 total)
  • Stef

    (@serafinnyc)

    Autoptimize didn’t work for you?

    Optimizing Matters

    (@optimizingmatters)

    AO doesn’t optimize the wp-admin dashboard Stef 🙂

    frank (ao dev)

    Stef

    (@serafinnyc)

    @optimizingmatters I didn’t read it that way. Eh?

    Optimizing Matters

    (@optimizingmatters)

    well, given the title is “Minifying CSS & JS in WP-Admin Dashboard”, that’s what I assumed the OP was aiming for 😉

    Stef

    (@serafinnyc)

    I never assume anymore. Too many language barriers and that never really translates well here. This from a French man who knows the struggle is real Frank! LOL

    Optimizing Matters

    (@optimizingmatters)

    🙂

    Joy

    (@joyously)

    What’s the actual question?

    Thread Starter danielmoorehbd

    (@danielmoorehbd)

    @joyously – The question is about minifying JavaScript and CSS when using the WordPress Dashboard.
    There are loads of plugins out there that minify JS, HTML & CSS on the front of the website but the dashboard remains slow, upon viewing the source of the pages in wp-admin it is clear that there is loads of plugin JS & CSS that is not minified, each file is loading seperatley and managing content in the back of the website is really slow, so I’m after something that could speed this up.

    Previously, I’ve dived into each and every offending plugin and manually removed the files slowing us down (if that file isn’t needed of course!) but whenever a plugin update comes through, that is undone.

    I’ve tried using wp_deregister_script & wp_deregister_style in functions.php but it doesn’t seem to work at all!

    Thread Starter danielmoorehbd

    (@danielmoorehbd)

    @serafinnyc & @optimizingmatters
    I haven’t tried the plugin, please note, front end caching is already in hand! It’s the back that I need assistance with, I can’t seem to hook into wp-admin in any way at all!

    Stef

    (@serafinnyc)

    @danielmoorehbd got it. I never want to assume because I’m never sure of someone’s knowledge of the platform.

    Joy

    (@joyously)

    Hopefully you don’t have the DEBUG constants defined. When you do, WP will load the unminified versions of CSS and JS. Otherwise, it should be loading minified files.
    As for plugins, they do what they want.

    There is this Note on
    https://developer.ww.wp.xz.cn/reference/functions/wp_deregister_script/

    Note: there are intentional safeguards in place to prevent critical admin scripts, such as jQuery core, from being unregistered.

    There is the script_loader_src filter. Make sure of your context before modifying.
    https://developer.ww.wp.xz.cn/reference/hooks/script_loader_src/

    Thread Starter danielmoorehbd

    (@danielmoorehbd)

    @serafinnyc That’s cool, thank you 🙂

    Thread Starter danielmoorehbd

    (@danielmoorehbd)

    @joyously The plugin’s having a free-for-all is 100% the problem, but I’ve managed to get a clutch overall on the site.

    I’ve downloaded and tweaked this: https://ww.wp.xz.cn/plugins/gonzales/
    Works a charm! (Stops things loading in the first place rather than minifies)

    Amazing how caching plugins aren’t yet all over the back-end area of the site. I appreciate there are some things plugins load at the back that are required for some plugins to work but most of the time, it’s just silly!

    Thanks all for your assistance.

Viewing 13 replies - 1 through 13 (of 13 total)

The topic ‘Minifying CSS & JS in WP-Admin Dashboard’ is closed to new replies.