This issue has been created
 
 
XWiki Platform / cid:jira-generated-image-avatar-34b0bcf4-a506-491e-ace9-9689d6ed264e XWIKI-25008 Open

Coalesce the front-end localization queries of a page into a single REST request

 
View issue   ยท   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-4a2f9d30-08f1-47d7-8468-299ca08ab543 Manuel Leduc created this issue on 17/Sep/26 09:47
 
Summary: Coalesce the front-end localization queries of a page into a single REST request
Issue Type: cid:jira-generated-image-avatar-34b0bcf4-a506-491e-ace9-9689d6ed264e Improvement
Affects Versions: 17.10.0-rc-1
Assignee: Unassigned
Components: Localization
Created: 17/Sep/26 09:47
Labels: performance
Priority: cid:jira-generated-image-static-major-39f65e72-e79c-4644-9c26-ccccc245ef3c Major
Reporter: Manuel Leduc
Description:

Context

xwiki-l10n, the RequireJS loader plugin registered by the localization webjar, resolves one query per dependent module: its load() implementation in l10n.ts calls resolver.resolve(query), and initialize only chains translators. Neither batches. Each xwiki-l10n!<keys module> dependency on a page therefore issues its own GET on /rest/wikis/<wiki>/localization/translations.

Actual

A standard page view already triggers several independent requests, one per consumer, for instance:

  • search-suggest-messages, from searchSuggest.js
  • xwiki-lightbox-messages, from lightbox.js
  • xwiki-job-messages, from job.js, on the pages that load it

Every piece of front-end code that drops its Velocity-generated translations in favour of xwiki-l10n, which is the recommended direction, adds one more request.

Expected

The queries issued during the same tick are coalesced into a single request, so that the number of localization requests per page view does not grow with the number of front-end components.

Suggested fix

Batch in the resolver returned by initialize, or in the xwiki-l10n plugin itself: collect the queries of a microtask or of a short window, send the union of their keys in one REST call, then dispatch the result back to each caller. The REST resource already accepts several keys per request, and the plugin already removes the query prefix and keeps only the keys it asked for, so most of the dispatch logic is in place.

Note that this also shortens the path to the first registration of anything that needs a translation before it can initialise.

Related: XWIKI-24851, which moves a Flamingo skin script to xwiki-l10n and so adds one such request.