Categories
Web Development

Is your Easy Digital Downloads AJAX request taking too long to load?

TLDR: If you want faster credit card AJAX load times in EDD, disable the “Show previously used cards” setting in EDD.

Hint: It only happens when you or a customer are logged-in.

I’ve recently found that it can take up to 8 seconds for the credit card fields to load when working on the GravityView website in a local environment.

I thought maybe there were other plugins loading during the admin-ajax.php call that were adding load time.

Request timing for EDD credit card admin-ajax call showing 8171ms.
Over 8 seconds to load the credit card HTML?

The load time was a problem only when a user is logged-in and when using the EDD Stripe payment gateway.

The issue? The “Show previously used cards” setting.

The "show previously used cards" setting in Easy Digital Downloads.

When “Show previously used cards” is enabled, there’s a round-trip request to Stripe to ask for the user’s saved credit cards. No big deal, right?

In production, that request takes ~1.7 seconds with the setting enabled. That’s not ideal, but it’s okay because it’s loading asynchronously. With the setting disabled, the AJAX request is .5 seconds faster.

In my testing environment, the request takes 8 seconds with the setting enabled, and only 0.5 seconds when disabled!

I’m turning the “Show previously used cards” setting off in my local environment and saving 8 seconds of my life each time I view the checkout page.

For the GravityView site, I’m going to leave the setting enabled. I think the .5 second tradeoff is worth the increased ease of use for customers.

By Zack Katz

Zack Katz is the founder of GravityKit and TrustedLogin. He lives in Leverett, Massachusetts with his wife Juniper.