• Resolved amitramani

    (@amitramani)


    So I have been using AO for a while now, without any issues. Just yesterday, I moved the site to WP Engine. Ever since then, there seems to be conflict between the CSS and JS loading. I notice that if I have “Optimize CSS” enabled on the AO settings, the site loads without CSS. Also, JS functionality is broken when I enable “Optimize JS” from the AO settings.

    The effect is more pronounced on mobile devices. I have asked WP Engine for help, but their solution is to disable AO.

    Can anyone here offer any tips on how to get AO working without any site rendering issues?

Viewing 4 replies - 16 through 19 (of 19 total)
  • Thread Starter amitramani

    (@amitramani)

    Sorry, I should have mentioned the error (it occurs on both the cart and checkout page)
    Uncaught ReferenceError: Stripe is not defined
    at VM380 autoptimize_720fb03….js:70
    (anonymous) @ VM380 autoptimize_720fb03….js:70

    Here is the code:
    Stripe.setPublishableKey(wc_stripe_apple_pay_params.key)

    I tracked the above code down to be originating from “woocommerce-gateway-stripe\assets\js\stripe-apple-pay.js”. That is being included by
    https://github.com/woocommerce/woocommerce-gateway-stripe/blob/26bf3a4899fd9c75e2ae7bfd47ecc4e090e9ac90/includes/class-wc-stripe-apple-pay.php#L288

    Sorry I was vague in my description in the last post. The change from AO from Dynamic to Static is not causing this. When I disable AO altogether, the errors disappear.

    Thread Starter amitramani

    (@amitramani)

    I did some more experimentation.

    If I exclude “stripe-apple-pay” using Exclude scripts from Autoptimize, the error goes away.

    So this might be some kind of jQuery conflict of some sort?

    Plugin Author Frank Goossens

    (@futtta)

    not jQuery especially, just JS.

    there are 2 possibilities;
    * stripe-apple-pay.js is included before the inline stripe JS, but the aggregated stripe-apple-pay.js is loaded after the inline JS (due to default AO behavior of deferring aggregated JS) -> the inline JS complains
    * stripe-apple-pay.js is included after the inline stripe JS, but you’re ‘forcing JS in head’ -> aggregated stripe-apple-pay.js complains

    2 possible solutions:
    * exclude stripe-apple-pay.js (as you so cleverly did)
    * enabled “also aggregate inline JS” (which has other disadvantages)

    so I guess you’re right were you have to be, really ??

    Thread Starter amitramani

    (@amitramani)

    Thanks, Frank!
    The second possibility is what is causing the conflict. (* stripe-apple-pay.js is included after the inline stripe JS, but you’re ‘forcing JS in head’ -> aggregated stripe-apple-pay.js complains)

    I am hoping this will fix the problem! Thanks again for such prompt responses!

Viewing 4 replies - 16 through 19 (of 19 total)
  • The topic ‘Need help for debugging on WP Engine’ is closed to new replies.