• Resolved madhavaji

    (@madhavaji)


    Hi,

    A client of ours who uses your “Braintree For WooCommerce” plugin asserted to me today that the plugin runs your localize_payment_methods() function on every page load and that this may be adversely affecting performance. They claim that whilst the function is running on every page there are only a few select pages where it actually needs to be run.

    Does that sound true to you? If so is there a way of fixing this?

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Clayton R

    (@mrclayton)

    Hi @madhavaji,

    Thank you for contacting us. The method localize_payment_methods is called under the following conditions:

    1. Are payment methods enabled on product page? Then it’s called
    2. Are payment methods enabled on cart? Then it’s called
    3. Is the mini-cart enabled with payment methods? Then it’s called.
    4. The Payment Methods page.

    That function technically only needs to be called if it’s the checkout page, order pay page, or subscription change payment method page. But the performance for checking those if statements is about the same as just calling the localize_payment_methods when the above conditions are met and it reduces the complexity of the script loading logic. That is why I coded it that way.

    Does your client have any performance tests that indicate that is affecting page speeds? In my testing it was negligible when you consider the other logic server side.

    Kind Regards,

    Thread Starter madhavaji

    (@madhavaji)

    Thanks for the speedy and detailed response @mrclayton ..

    I ran some more tests having taken in the logic you detail in your reply.

    What you say is true. I have reported back to my client that all is well here.

    Thanks for your time!

    Thread Starter madhavaji

    (@madhavaji)

    Resolved!

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

The topic ‘localize_payment_methods() function runs on every page load?’ is closed to new replies.