woocommerce / woocommerce-gateway-paypal-express-checkout

59 stars 64 forks source link

paypalobjects.com/muse/noop.js seems to slow down the site #776

Closed nielslange closed 4 years ago

nielslange commented 4 years ago

Describe the bug

In #22086916-hc, a customer reported that the file paypalobjects.com/muse/noop.js slows down their site. This file seems to be loaded by the WooCommerce PayPal Checkout Payment Gateway extension. After deactivating the extension, their site was loading fast again.

To reproduce

  1. Install and activate the WooCommerce PayPal Checkout Payment Gateway extension
  2. Go to https://gtmetrix.com/ and run a speed test
  3. Look up the waterfall chart

Screenshots

Screenshot 2020-06-22 at 15 11 17

Additional details

I wonder if this issue is actually caused by the WooCommerce PayPal Checkout Payment Gateway extension or if the PayPal server simply responds too slow, which causes this issue.

achyuthajoy commented 4 years ago

Hey @nielslange!

PPEC plugin loads only the PayPal SDK JS, which dynamically introduces additional scripts. From the info you've shared it seems the slowness comes from PayPal's end. Also I noticed a few similar reports on a Google Search mentioning the same problem on different platforms.

Let's see if anyone else has more info on this.

aheckler commented 4 years ago

Followed up with this user in chicket: 3082937-zen.

jorgeatorres commented 4 years ago

Hi @aheckler!

As @achyuthajoy has explained, we only load a single script from PayPal. The rest is them. As such, I don't think there's anything we can do from our end. I couldn't even get the PayPal scripts to load this "noop.js" script on my local instance, but I did see this on the customer's site, though not consistently. Even in those cases, the file loaded quickly.

So, that this file is being loaded is probably the result of a decision tree somewhere in PayPal's code, which we don't control. Also, this is a 1 B file (that's why it is called "noop"), so it shouldn't take 14 seconds to load. Maybe this whole issue might be due to temporary server-side problems on PayPal's side.

I'm going to close this issue for now, but feel free to re-open if you feel I missed something.

eggsdev commented 4 years ago

@jorgeatorres

Same issue we were experiencing with one of our clients. This plugin increased website loading for 20-21 seconds :( I never saw anything like this, so there is definitely an issue with this, guys. We deactivated the plugin, but standard PayPal option is not working for us.

Can you find any solutions?

achyuthajoy commented 4 years ago

Hey @eggsdev!

Like we've mentioned on previous responses, we're only adding couple of JS files for the checkout feature to work properly. The rest of the process is handled by the PayPal SDK. Unfortunately, we don't have any control over the files included by the SDK.

LCmry commented 4 years ago

@EktaPayPal can you look into this on PayPal's side?

jessuppi commented 4 years ago

I also noticed PayPal's noop.js loading extremely slowly on a client's site, and began looking into this. For the record, this issue appears to involve several different PayPal plugins for WooCommerce, not only this one.

TLDR try a different WordPress theme or disable your "sidecart" plugin, etc.

More details: it seems to be caused by poor coding in WordPress themes and/or certain cart/checkout plugins (not necessarily the PayPal plugins, although in some cases, those too). Specifically, PayPal has very clear best practices for how to optimize loading of their SDK, and some payment processing plugins for WooCommerce either ignore this (e.g. loading the SDK as part of a general tag manager function, which ironically, is sometimes recommended by PayPal) or alternatively, adding a ton of AJAX and JS in the mix that can end up conflicting with the loading of noop.js and SDK et al.

In other words, as with many situations in WordPress, it can be caused by a combination of theme/plugins/etc because too many developers never consider "other" extensions.

P.S. many devs think it's a good idea to block e.g. PayPal assets on non-checkout pages, but this can be a bad idea for a variety of reasons e.g. it prevents preloading... the link above has specifics.

Edit: if these solutions still don't work for you, look at other JS-related assets that might be conflicting too.