Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: America/Los_Angeles (GMT-08:00)

This topic contains 13 replies, has 2 voices.

Last updated by Bobby 4 months, 1 week ago.

Assisted by: Bobby.

Author Posts
June 5, 2024 at 5:50 pm #15708162

pawelM-9

Background of the issue:
We are currently experiencing an issue with the WPML plugin on our website related to language switching. When users switch languages, an AJAX request is triggered, which causes a delay of approximately 2-3 seconds. This delay negatively impacts the user experience as it slows down the entire language switching process. admin-ajax.php action: switching_language

Symptoms:
Delay of approximately 2-3 seconds when switching languages using WPML.

Questions:
How can we optimize the AJAX request to reduce the delay and improve the overall performance?
Are there specific configurations or code adjustments we can implement to speed up this process?
What are the best practices for handling AJAX requests in WPML?

June 5, 2024 at 6:05 pm #15708489

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

Hello,

Please review this documentation and verify that the feature to support Ajax filtering is activated.

Let me know your results, please.

June 6, 2024 at 9:18 am #15709945

pawelM-9

regardless of whether this option is enabled or disabled, such an AJAX request appears and takes so long

June 6, 2024 at 6:22 pm #15713072

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

The "admin-ajax.php" file contains all the code for routing Ajax requests on WordPress.

WordPress uses it to refresh the page’s contents without reloading it, thus making it dynamic and interactive to the users.

Removing it is not possible, however, we can review your site to verify that everything is configured in the best way possible to increase performance.

I would like to request temporary access (wp-admin and FTP) to your site to test the issue.
(preferably to a test site where the problem has been replicated if possible)

**Before we proceed It is necessary to take FULL BACKUP of your database and your website. Providing us with access, you agree that a backup has been taken **

I often use the Duplicator plugin for this purpose: http://wordpress.org/plugins/duplicator/
You will find the needed fields for this below the comment area when you log in to leave your next reply.
The information you enter is private which means only you and I have access to it.

NOTE: If access to the live site is not possible and the staging site does not exist please provide me with a duplicator package created with the duplicator plugin.

Thank you,
Bobby

June 14, 2024 at 10:42 pm #15741334

pawelM-9

I uploaded the site copy file to the public_html folder

June 19, 2024 at 8:06 am #15753752

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

Thank you for uploading it to the directory, unfortunately, I am still having trouble deploying this package.

May I ask you to please use the information I shared above to migrate a copy of the site to our cloudways server, this will allow us to ensure the migration is not corrupted.

June 24, 2024 at 5:32 pm #15810039

pawelM-9

Unfortunately, two attempts ended with errors:

I am also unable to transfer it manually because there is a problem with uploading the database to their database.

Should I share a dev copy of the website on the server?

hidden link
Last:
hidden link

June 24, 2024 at 6:21 pm #15810399

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

Yes, I am afraid due to the size it is failing.

If you can share a dev copy on the server that our team can access that would be great as it would allow us to test further and get you a solution faster 🙂

I have enabled the private field reply to share access to the dev copy.

Thank you!

June 26, 2024 at 7:34 pm #15836893

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

Hi there,

I have done a few tests and see the following (see screenshot).

The admin-ajax.php has a high load time and the payload is indeed switching_language.

However, testing on your staging server where the different domain per language is not used (languages in directories ) the admin-ajax.php action is not triggered nor does it have such high load.

Additionally testing on the live site, IF I remove the parameter /?_gl= this is not triggered either.

Is this parameter being added by Google Analytics or Tag Manager for the cross domain tracking or another 3rd party plugin?

What are your results if you temporarily deactivate it?

Screen Shot 2024-06-26 at 12.13.43 PM.png
Screen Shot 2024-06-26 at 11.53.51 AM.png
Screen Shot 2024-06-26 at 11.52.24 AM.png
June 26, 2024 at 9:03 pm #15837345

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

To add to my previous message, also go to WPML->Languages -> Language URL Format and uncheck the option for the " Auto sign-in /sign-out feature".

Let me know your results, please.

June 27, 2024 at 7:23 am #15841233

pawelM-9

I have disabled the "Auto sign-in/sign-out feature" option

However, despite this, the whole process is slow.

As for the ?_gl parameter, it is related to Google Analitycs. Does this affect the speed of admin-ajax queries?

June 27, 2024 at 6:19 pm #15846015

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

Thank you, when I run the same test now admin-ajax.php is no longer giving an err 400 which seems to be related to the "Auto sign-in/sign-out feature" option.

Let's continue with some more testing. Is it possible to temporarily deactivate the
?_gl parameter, i would like to test if this is related to the performance issue you are getting.

what I notice is that it is the ?_gl parameter that is the initiator of the admin-ajax.php query now and that the page loads OK, however it takes up to 3-4seconds to fully load, and once it does that is when the parameter is added to the URL.

In summary this is what I see--> page loads all content OK, but keeps loading, does a quick refresh and the parameter is added

July 8, 2024 at 9:44 pm #15915747

pawelM-9

Disabling the plugin that adds the Google Analytics code does not solve the problem.

Such redirections no longer occur, but there is still a delay of a few seconds

July 9, 2024 at 8:41 pm #15923232

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

Thank you for updating me!

I no longer see the admin-ajax.php errors or delays logged anymore. Also, I no longer see that delayed load issue I described in my previous reply.

The loading time for the front end with WPML activated is 5.23s looking at the TTFB (time to first byte)

with WPML deactivated it's 3.12s

The difference is around 2-3 seconds of added load time. (aligned with what you mentioned)

4.28s now

After doing the following, I got the loading time down to 1.90 when signed out and tested in an incognito window.

1. Go to WPML->Support->Troubleshooting-> Run the Troubleshooting actions.

"Cleanup and optimize string tables"
"Clear invalid strings"
"Remove ghost entries from WPML tables".

2. On the same page, click Remove strings that are not needed and untranslated strings and remove.

3. Enabled Store a language cookie to support language filtering for AJAX

4. Install the plugin Index WP MySQL For Speed

Screen Shot 2024-07-09 at 1.37.19 PM.png

The topic ‘[Closed] WPML AJAX switching_language’ is closed to new replies.