ข้ามการนำทาง
34

We just released WPML 4.3, which includes a completely new way of translating strings. The String Translation admin looks the same but works differently. Instead of reading translations from the database, it generates and loads .mo files. This results in much lighter database usage for string translation.

Why Did We Rewrite String Translation?

The previous version of string translation loaded the strings from the database and attempted to avoid loading .mo files. Some of the large WordPress plugins come with huge .mo files, which translate each and every text in the plugin. For example, WooCommerce .mo files have a bit over 8,000 strings. Other large plugins have similar string counts.

When you run a site in English, WordPress doesn’t load these .mo files. However, when you run a site in any other language (just one language, not multilingual sites), WordPress will load all these .mo files. Loading these files takes anywhere from 100ms to over a second, depending on the server you’re using. These .mo files will load on any page on which the plugin runs (typically, on all the site’s pages).

Until WPML 4.3, we attempted to optimize this mechanism. WPML had an option, which was enabled by default, to prevent the theme and plugins from loading .mo files. Instead, we checked which strings are needed for each page and we loaded these specific strings from the database.

The mechanism worked well in general, but sometimes it backfired. When a plugin hits many strings on every page load, WPML would load a huge list of strings from the database instead of letting the plugin load its own .mo file.

As some plugins grew over time, our optimization mechanism became less and less efficient.

In WPML 4.3 we decided that it’s time to change the approach. We’ve stopped blocking .mo files and we’ve stopped loading strings from the database. Now WPML doesn’t attempt to optimize the translation times of other plugins or themes, and only optimizes its own strings.

How Will This Affect My Site’s Load Time?

This depends. If your site was fast until now (which the majority of the sites using WPML are), you’re not going to feel a significant change in speed. For example, on wpml.org, most pages are a little faster and a few pages take a little more time to load.

The reason why some pages take a little longer to load now is because there are other plugins loading huge .mo files. The speed increase from optimizing string translations is canceled out by the .mo file loading times of other plugins.

However, these fluctuations are very small and we can only measure them with advanced profiling tools. A website that ran fast until now will generally continue running fast with WPML 4.3.

Some websites that suffered from slow load times will now load much faster. Prior to WPML 4.3, some websites had tens of thousands of strings to load from the database. This caused a significant load on the database, consumed a lot of RAM and caused long page load times. These sites will see a very significant improvement in performance.

Any More Performance Optimizations Coming?

Yes. Now that we’ve removed the major performance issues coming from string translation, we’ll have more opportunities for optimization.

We’re expecting to find issues that will require work with the authors of other plugins and themes. Performance improves the most when plugins and themes load fewer strings. Most other plugin and theme authors are happy to work with us and we’re confident that we can resolve almost every performance issue that comes next. The optimization process is almost always the same:

  • Split huge .mo files into several smaller files
  • Load the right files on the right pages

The trivial segmentation is between strings that are used on the admin and strings that display on the front-end. Deeper optimizations further split front-end strings according to the type of page. For example, on e-commerce sites, there’s no need to load the strings used in the checkout process on every page.

Of course, when there’s an opportunity for optimization within WPML itself, we take care of it immediately.

Update, Measure and Report

WPML 4.3 is being deployed right now. We’re releasing it gradually over one or two weeks. If your sites haven’t received this update yet, give it some time and you’ll see the update in a few days. You can skip the queue and get this update immediately by going to Plugins –> Add New page, clicking the Commercial tab and then using the Check for updates button.

If you feel that any page on your site takes longer to load, we suggest you install the Query Monitor plugin (follow our tutorial on how to analyze performance issues with Query Monitor). Note that in WPML 4.3 we fixed significant compatibility problems with Query Monitor, so the reports that you see are not useful for versions before WPML 4.3.

See if WPML calls are starring in the load reports. If so, please report to us in WPML technical support. Even if you see threads that appear similar, start your own. We’ll need access to your site so it’s better to work on each site separately.

Of course, we’ll be very glad to hear your general updates about performance (it’s equally helpful to report improvements 🙂). Leave your comments here and we’ll get back to you.