WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 6 years ago

#27797 closed defect (bug) (fixed)

Improve loading of TinyMCE translations

Reported by: nacin Owned by: azaozz
Milestone: 4.1 Priority: low
Severity: minor Version:
Component: TinyMCE Keywords:
Focuses: performance Cc:

Description

[28112] loads all translations even in English. In reality only about 10 strings diverge from the TinyMCE string in en_US, so we could speed things up with some creativity. (We're only talking a millisecond, however.)

Additionally, a lot of these strings are there only for plugins — we can check if the table plugin is added, and then immediately side-step 40 translations. The whole process takes about 4-5 milliseconds; we might be able to cut that in half if we exclude strings we don't need when that particular plugin isn't loaded.

TinyMCE 4.0 uses real English string fallbacks, so it's less of a problem if something doesn't get translated because custom plugin B is using official plugin A's strings.

Attachments (1)

27797.patch (664 bytes) - added by azaozz 6 years ago.

Download all attachments as: .zip

Change History (7)

This ticket was mentioned in IRC in #wordpress-dev by nacin. View the logs.


7 years ago

#2 @azaozz
7 years ago

  • Owner set to azaozz
  • Status changed from new to assigned

#3 @azaozz
6 years ago

...a lot of these strings are there only for plugins — we can check if the table plugin is added, and then immediately side-step 40 translations.

This may fail when another instance of TinyMCE is created after loading the page. If that instance loads plugins that are not loaded in the initial instance, TinyMCE will load the plugin's JS but expects that the translations are already present. This changed in version 4.0. Now all translations for the default plugins are always loaded. In 3.x there were separate translation files for the plugins, now all are merged in one.

[28112] loads all translations even in English. In reality only about 10 strings diverge

Right, we can output only strings that diverge from the default. This won't speed things up but will output less inline JS (the translated strings are outputted inline from PHP to avoid another request).

@azaozz
6 years ago

#4 @azaozz
6 years ago

In 27797.patch: don't output strings that are not translated. Reduces the size of the inline JSON from 5.4k to 1.1k for en_US.

#5 @azaozz
6 years ago

  • Milestone changed from Future Release to 4.1

#6 @azaozz
6 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 30294:

TinyMCE: remove strings that are not translated before outputting the translations. Fixes #27797.

Note: See TracTickets for help on using tickets.