This issue has been created
 
 
XWiki Platform / cid:jira-generated-image-avatar-5f7c1f35-90a5-4c28-87fd-f65952718053 XWIKI-24851 Open

2.16 KB of static keyboard-shortcut script is inlined in every page instead of being a cacheable skin file

 
View issue   ·   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-79f437ad-dd57-46d2-ba55-7cf553eec4a1 Manuel Leduc created this issue on 09/Sep/26 15:35
 
Summary: 2.16 KB of static keyboard-shortcut script is inlined in every page instead of being a cacheable skin file
Issue Type: cid:jira-generated-image-avatar-5f7c1f35-90a5-4c28-87fd-f65952718053 Improvement
Affects Versions: 17.10.0-rc-1
Assignee: Unassigned
Components: Flamingo Skin
Created: 09/Sep/26 15:35
Labels: performance
Priority: cid:jira-generated-image-static-major-7b4e255b-2a00-4b58-9275-95b0a426c3af Major
Reporter: Manuel Leduc
Description:

Context

Measured on a plain page view (Sandbox.WebHome, no images, no comments, no macros, 18.8.0-SNAPSHOT), the server sends a 93,113-byte HTML document of which about 63% is not useful at first paint: 33.5 KB of markup for dialogs and menus nobody opened, and 24.9 KB of inline <script>. The overhead is a near-constant 51-57 KB per page view whatever the page contains, and the document is not compressed, so those are real bytes on the wire every time.

Reproduction steps

  1. Visit http://localhost:8080/xwiki/bin/view/Sandbox/
  2. Find the inline <script> block containing the comment "Perform a PUT on the given REST API" in the HTML source
  3. Visit another page and compare the two blocks

Expected

The keyboard shortcut definitions, which do not depend on the page, are served as a cacheable resource.

Actual

The block generated by flamingo/shortcuts.vm is 2,156 bytes — 2.3% of the document — and is byte-for-byte identical between Sandbox.WebHome and Main.WebHome, yet inlined, uncompressed and uncacheable on every page view.

Its Velocity source does call $services.localization.render(...) about 15 times, so the output varies by locale — but not by page, user or rights.

Suggested fix

Serve it as a Velocity-evaluated JS skin file with the locale in the cache key, which is precisely the existing pattern — flamingo/editinline.vm:24:

$xwiki.jsfx.use('uicomponents/widgets/fullScreen.js', {'forceSkinAction': true, 'language': ${xcontext.locale}})

No trade-off: one cached file per locale instead of 2.16 KB on every page view.

Taken together with the two companion issues about javascript.vm and docextra.vm, moving these three static blocks out of the document removes 16.4 KB, 17.5% of every page view, with an existing in-repo pattern to copy for all three.