Support » Plugin: Autoptimize » Trouble with filtering with Woo, Autoptimize, & FacetWP working together

  • Xizor81

    (@xizor)


    I’m having consistently terrible trouble getting woocommerce’s ajax filtering, autoptimize, & facetwp to work together without the following error.

    I’ve tried excluding the entire plugin folders of woocommerce & facetwp from inside of autoptimize, but nothing.

    I can only get the ajax filtering for woocommerce & facetwp to work IF javascript optmizations are turned off in autoptimize, but that obviously negates a tremendous amount of autoptimize’s functional value.

    Screenshot of DevTools Console Error:
    https://imgur.com/a/mQ5dPpU

    Does anyone have any ideas?

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Optimizing Matters

    (@optimizingmatters)

    Can you share the URL of your site so I can see how ajax filtering & facetwp work xizor ?

    Thread Starter Xizor81

    (@xizor)

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    The problem seems to be with the AJAX response being full HTML and being optimized by AO. Can you try this code snippet;

    add_filter( 'autoptimize_filter_noptimize', 'fwp_noptimize', 10, 1 );
    function fwp_noptimize( $flag_in ) {
        if ( strpos( $_SERVER['REQUEST_URI'], 'fwp_' ) !== false ) {
            return true;
        } else {
            return $flag_in;
        }
    }
    Thread Starter Xizor81

    (@xizor)

    I appreciate your snippet, thank you for taking time to provide it as a potential solution.

    This snippet allows for the first filtering task to work, but clicking ‘Reset filters’ or attempting to use the woocommerce built in ‘sorting order’ still won’t work after this.

    Basically, you get one shot at using facetWP filter and your filtering days are over lol. It benches woocommerce sorting completely.

    Screenshot:

    https://imgur.com/a/8GjjKTz

    1. Error #1 Clicking ‘Reset filters’
    2. Attempting to use woocommerce sorting order

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    weird stuff … the AJAX reponse is sent with content-type text/json and is parsed as JSON, but actually is HTML, even when AO is off (by virtue of ?ao_noptimize=1) and things do work.

    is that really how it is supposed to work? can’t seem to wrap my head around this one (yet) .. :-/

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    so head-wrapping aside; what happens if you exclude wp-content/plugins and/or wp-content/themes and/or wp-includes/js?

    Thread Starter Xizor81

    (@xizor)

    It is ‘weird stuff’!!. The fact that json was involved at all was one of the things that was completely throwing me for a loop.

    I’m going to attempt your suggestions now and I’ll report back.

    I am using Oxygen builder so I have no ‘proper theme’ as it were.

    Brb.

    Thread Starter Xizor81

    (@xizor)

    I’m still seeing the ‘Uncaught SyntaxError: Unexpected token < in JSON at position …” error even after making the exclusions of:

    wp-content/plugins, wp-content/themes, wp-content/js

    I did think that I experienced one working iteration in the beginning which had be believing that these exclusions were working. However, they didn’t continue to work. I’ve since tried several times to clear autoptimize caching and see if it would work for me (even if only for one itereation), but I haven’t been able to reproduce that success…

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    did you try wp-content/js or wp-includes/js xizor ? and do you have “also aggregate inline JS” on (if so test without it)?

    and just to make sure; can you disable HTML & CSS & Image optimization too?

    Thread Starter Xizor81

    (@xizor)

    Including wp-content/js and wp-includes/js didn’t work and created additional errors so I rolled back that change.

    I revisited excluding wp-content/plugins while turning off ‘Aggregate Inline JS’ and it seems to work.

    So…

    I systematically added the exclusion of wp-content/each-of-my-plugins-individually but this did not work. It resulted in the same error we’ve been wrestling with.

    I created a second testing site and I tracked down that I can create the error we’ve been seeing when the plugin Webp-Express is activated. So… I added the autoptimize exclusion of wp-content/plugins/webp-express and voila! The second testing site works. So…

    Back on my main staging site, I deleted the exclusion of wp-content/plugins and added wp-content/plugins/webp-express … it doesn’t help. Back to square one.

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    I revisited excluding wp-content/plugins while turning off ‘Aggregate Inline JS’ and it seems to work.

    OK, that’s progress.

    I systematically added the exclusion of wp-content/each-of-my-plugins-individually but this did not work. It resulted in the same error we’ve been wrestling with … I deleted the exclusion of wp-content/plugins and added wp-content/plugins/webp-express … it doesn’t help.

    you will probably have to exclude more then one plugin. doesn’t make the troubleshooting any easier though .. maybe start testing with just WooCommerce, FacetWP & Autoptimize and then re-activate plugins one by one?

    and did you indeed disable CSS & HTML & img opt. to make sure those are not involved?

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    any news here @xizor ?

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Trouble with filtering with Woo, Autoptimize, & FacetWP working together’ is closed to new replies.