• Resolved Butterfly88

    (@butterfly888)


    Hi there,

    I am using Asset Cleanup in combination with WPO. This has been working great for the most part. In order to be able to unload assets, I need to instruct WPO not to minify those applicable assets on certain pages and disable preload.

    With the help of your documentation, I have succesfully created various filters for conditional minification. This means that the minification only happens on the urls I want to. In some case only 1 page on the entire website. This has been working properly for me on regular WordPress pages.

    Unfortunately, I don’t seem to be able to do this with BuddyPress pages. It simply won’t minify there. Below is the code I used. Can you please provide me feedback why this is not working and what I should do differently?

    add_filter('wp-optimize-minify-default-exclusions', function($exclusions) {
    $current_url = $_SERVER['REQUEST_URI'] ?? '';

    $allow_minify = false;

    if (strpos($current_url, '/members/') === 0) {
    $allow_minify = true;
    }

    if (rtrim($current_url, '/') === '/activity') {
    $allow_minify = true;
    }

    if (!$allow_minify) {
    $exclusions[] = 'bp-toolkit/';
    $exclusions[] = 'buddypress-activity-share-pro/';
    $exclusions[] = 'buddypress-media/';
    $exclusions[] = 'buddypress-reactions/';
    }

    return $exclusions;
    });

    add_filter('wp-optimize_minify_css_exclusions', function($exclusions) {
    $current_url = $_SERVER['REQUEST_URI'] ?? '';

    $allow_minify = false;

    if (strpos($current_url, '/members/') === 0) {
    $allow_minify = true;
    }

    if (rtrim($current_url, '/') === '/activity') {
    $allow_minify = true;
    }

    if (!$allow_minify) {
    $exclusions[] = 'bp-toolkit/';
    $exclusions[] = 'buddypress-activity-share-pro/';
    $exclusions[] = 'buddypress-media/';
    $exclusions[] = 'buddypress-reactions/';
    }

    return $exclusions;
    });

    add_filter('wp-optimize_minify_cache_increment', function($increment) {
    $current_url = $_SERVER['REQUEST_URI'] ?? '';

    if (strpos($current_url, '/members/') === 0) {
    return $increment . '_members';
    }

    if (rtrim($current_url, '/') === '/activity') {
    return $increment . '_activity';
    }

    return $increment . '_no_minify';
    });
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Damilare

    (@deabiodun)

    Hi!
    The filters you’ve applied look quite good.
    Before I make further comments, please provide some BuddyPress paths (full URL) you expect to be included for minification.

    Regards.

    Thread Starter Butterfly88

    (@butterfly888)

    Hi Damilare,

    Thank you for your swift response. Please find the requested information in below paste:

    URL:https://pastebin.com/ZZjZfzQV
    pass: GnGhWaWXvs

    Thank you in advance.

    Thread Starter Butterfly88

    (@butterfly888)

    Seems to be minifying now (apparantly it took some time?) closing ticket.

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

The topic ‘Conditional minification on certain pages’ is closed to new replies.