Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-24851

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

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Unresolved
    • Major
    • None
    • 17.10.0-rc-1
    • Flamingo Skin
    • Unknown

    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.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              mleduc Manuel Leduc
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated: