[Resolved] Advanced Custom Fields Multilingual slow down my sites
This thread is resolved. Here is a description of the problem and solution.
Problem: If you're experiencing slow site performance when the Advanced Custom Fields Multilingual plugin is activated, it might be due to the high number of ACF field calls. In a case we investigated, activating WPML increased the load time significantly because it hooked into each ACF field call for translation, executing over 8000 times. Solution: To address this, we recommend two strategies: 1. Reduce the number of ACF field calls by modifying the theme to minimize usage of
acf_get_field
, especially for fields that don't require translation. Replace these with direct
get_post_meta
calls to bypass both WPML and ACF retrieval logic. 2. Use a filter introduced in ACFML 2.1.4 to bypass translation logic. Add the following code to your theme's
This code ensures that only fields marked for translation are processed, significantly improving performance.
If these solutions do not resolve your issue or seem outdated, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the problem persists, please open a new support ticket.
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.
Background of the issue:
I am trying to improve my site's load time. Currently, the load time without Advanced Custom Fields Multilingual is about 2 seconds, but with it, the load time increases to around 10 seconds. Here is a link to a page where the issue can be seen: hidden link.
Symptoms:
The website becomes slow when the Advanced Custom Fields Multilingual plugin is activated.
Questions:
Why does the Advanced Custom Fields Multilingual plugin slow down my site?
How can I reduce the load time when using the Advanced Custom Fields Multilingual plugin?
Let me know if I can test with and without ACFML, also, the performance issue is visible on hidden link, so this page will have visible issues on the performance side?
Languages: English (English )German (Deutsch )French (Français )
Timezone: Europe/Zagreb (GMT+01:00)
Can you please try the following:
1. Navigate to the file located at: `wp-content/plugins/acfml/classes/Strings/FieldHooks.php`.
2. Look for the method `\ACFML\Strings\FieldHooks::translateField` around line 56.
3. Modify the line:
if ( self::isAcfFieldGroupScreen() ) {
to
if ( self::isAcfFieldGroupScreen() || is_admin() ) {
Languages: English (English )German (Deutsch )French (Français )
Timezone: Europe/Zagreb (GMT+01:00)
To troubleshoot this problem, I'll install the Duplicator plugin and generate packages for further debugging purposes. I'll ensure to exclude all media files to maintain a minimal package size. You can find more information about the process here: [link](https://wpml.org/faq/provide-supporters-copy-site/). Please confirm if this approach is acceptable to you.
Languages: English (English )German (Deutsch )French (Français )
Timezone: Europe/Zagreb (GMT+01:00)
This has been escalated to our 2nd tier team team and may take some debugging time, I'll get back to you as soon as I have any news or questions for you.
Languages: English (English )German (Deutsch )French (Français )
Timezone: Europe/Zagreb (GMT+01:00)
We’ve been looking into the performance issues, and this case is somewhat unique in that the theme relies heavily on ACF fields. Without WPML activated, loading the home page triggers the ACF function `acf_get_field` over 8000 times. WPML then hooks into each of these calls to translate fields as needed, which means that translation logic is executed over 8000 times, leading to a significant performance hit.
There are two potential strategies to improve this:
1. **Reduce the Number of ACF Field Calls:**
The theme could be modified to minimize the number of `acf_get_field` calls, especially when retrieving field values that don’t require translation (e.g., fields without text labels, such as page options). These could be replaced with direct `get_post_meta` calls. This would bypass both the WPML translation logic and the ACF field retrieval logic, resulting in a much more efficient process.
2. **Use a Filter Introduced in ACFML 2.1.4:**
ACFML 2.1.4 introduced a filter that allows us to bypass translation logic altogether using this code:
While this significantly improves performance, it may be too broad, as it skips translation for all custom fields. To make it more precise, we implemented a workaround that only applies translation logic to fields explicitly set to be translated. Here’s the code we used, which could be added as a drop-in plugin or directly into the theme’s `functions.php`:
We quickly tested this code on a blank test page, and it seems to have improved TTFB from 9-10 seconds to around 4 seconds. It's much better, but there's still room for improvement. Could you explain more about the logic behind this filter and how it impacts WPML/ACF performance so significantly? Thank you for your time.
Languages: English (English )German (Deutsch )French (Français )
Timezone: Europe/Zagreb (GMT+01:00)
The filter defaults to $should = false, effectively bypassing translation for all ACF fields unless explicitly marked for translation in WPML’s custom_fields_translation settings. By limiting the translation checks only to fields with the WPML_TRANSLATE_CUSTOM_FIELD flag, it cuts down the number of fields WPML processes.
The filter also caches the custom_fields_translation array locally with static $customfield_settings, preventing multiple calls to get_option for each ACF field. This reduces database queries and improves processing efficiency by accessing the settings only once per page load.
This optimized translation logic reduces WPML’s workload by skipping unnecessary checks and queries. By streamlining how ACF fields are handled, it directly impacts Time to First Byte (TTFB), leading to faster initial server responses and overall page load improvement.