Page MenuHomePhabricator

VisualEditor injects a lot of JavaScript configuration variables
Closed, ResolvedPublic

Description

These are loaded on all requests on all pages, and thus should be simplified where possible.
Currently, from https://meta.wikimedia.org/w/load.php?modules=mediawiki.base&debug=true

"wgVisualEditorConfig": {
    "usePageImages": true,
    "usePageDescriptions": true,
    "isBeta": true,
    "disableForAnons": false,
    "preloadModules": [
        "site",
        "user"
    ],
    "preferenceModules": {
        "visualeditor-enable-experimental": "ext.visualEditor.experimental"
    },
    "namespaces": [
        4,
        200,
        202,
        null,
        206,
        2,
        6,
        12,
        14,
        0
    ],
    "contentModels": {
        "wikitext": "article"
    },
    "pluginModules": [
        "ext.wikihiero.visualEditor",
        "ext.cite.visualEditor",
        "ext.geshi.visualEditor",
        "ext.spamBlacklist.visualEditor",
        "ext.titleblacklist.visualEditor",
        "ext.score.visualEditor",
        "ext.confirmEdit.visualEditor",
        "ext.abuseFilter.visualEditor",
        "ext.CodeMirror.visualEditor.init",
        "ext.CodeMirror.visualEditor",
        "ext.citoid.visualEditor",
        "ext.templateDataGenerator.editPage",
        "ext.math.visualEditor",
        "ext.disambiguator.visualEditor",
        "ext.wikimediaEvents.visualEditor",
        "ext.TemplateSandbox.visualeditor",
        "ext.graph.visualEditor",
        "ext.kartographer.editing",
        "ext.kartographer.visualEditor"
    ],
    "thumbLimits": [
        120,
        150,
        180,
        200,
        220,
        250,
        300,
        400
    ],
    "galleryOptions": {
        "imagesPerRow": 0,
        "imageWidth": 120,
        "imageHeight": 120,
        "captionLength": true,
        "showBytes": true,
        "mode": "traditional",
        "showDimensions": true
    },
    "unsupportedList": {
        "firefox": [
            [
                "\u003C=",
                11
            ]
        ],
        "safari": [
            [
                "\u003C=",
                6
            ]
        ],
        "opera": [
            [
                "\u003C",
                12
            ]
        ]
    },
    "tabPosition": "before",
    "tabMessages": {
        "edit": null,
        "editsource": "visualeditor-ca-editsource",
        "create": null,
        "createsource": "visualeditor-ca-createsource",
        "editlocaldescription": "edit-local",
        "editlocaldescriptionsource": "visualeditor-ca-editlocaldescriptionsource",
        "createlocaldescription": "create-local",
        "createlocaldescriptionsource": "visualeditor-ca-createlocaldescriptionsource",
        "editsection": "editsection",
        "editsectionsource": "visualeditor-ca-editsource-section"
    },
    "singleEditTab": false,
    "enableVisualSectionEditing": "mobile",
    "showBetaWelcome": true,
    "allowExternalLinkPaste": false,
    "enableTocWidget": false,
    "enableWikitext": true,
    "useChangeTagging": true,
    "svgMaxSize": 4096,
    "namespacesWithSubpages": {
        "0": 1,
        "8": 0,
        "200": 1,
        "201": 1,
        "202": 1,
        "203": 1,
        "208": 1,
        "209": 1,
        "1": true,
        "2": true,
        "3": true,
        "4": true,
        "5": true,
        "7": true,
        "210": true,
        "9": true,
        "10": true,
        "11": true,
        "12": true,
        "13": true,
        "15": true,
        "100": true,
        "101": true,
        "102": true,
        "103": true,
        "104": true,
        "105": true,
        "106": true,
        "107": true,
        "108": true,
        "109": true,
        "110": true,
        "111": true,
        "112": true,
        "113": true,
        "114": true,
        "115": true,
        "116": true,
        "117": true,
        "118": true,
        "119": true,
        "830": true,
        "831": true,
        "828": true,
        "829": true,
        "1198": true,
        "1199": true,
        "867": true
    },
    "specialBooksources": "Special:BookSources",
    "rebaserUrl": false,
    "restbaseUrl": "/api/rest_v1/page/html/",
    "fullRestbaseUrl": "/api/rest_",
    "allowLossySwitching": false,
    "feedbackApiUrl": "https://www.mediawiki.org/w/api.php",
    "feedbackTitle": "VisualEditor/Feedback",
    "sourceFeedbackTitle": "2017 wikitext editor/Feedback",
    "transclusionDialogSuggestedValues": true,
    "transclusionDialogInlineDescriptions": false,
    "transclusionDialogBackButton": false,
    "transclusionDialogNewSidebar": false,
    "cirrusSearchLookup": false,
    "templateSearchImprovements": false
},

Some of these can be simplified, or are never changed and thus can be removed and the default values used instead

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change 723642 had a related patch set uploaded (by DannyS712; author: DannyS712):

[mediawiki/extensions/VisualEditor@master] Stop adding $wgSVGMaxSize to JavaScript config variables

https://gerrit.wikimedia.org/r/723642

Change 723642 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] Stop adding $wgSVGMaxSize to JavaScript config variables

https://gerrit.wikimedia.org/r/723642

Change 726948 had a related patch set uploaded (by DannyS712; author: DannyS712):

[mediawiki/extensions/VisualEditor@master] Refactor how namespaces with subpages are exposed to JavaScript

https://gerrit.wikimedia.org/r/726948

Change 726948 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] Refactor how namespaces with subpages are exposed to JavaScript

https://gerrit.wikimedia.org/r/726948

Change 817250 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/VisualEditor@master] Don't send missing $wgVisualEditorTabMessages to the browser

https://gerrit.wikimedia.org/r/817250

Change 817250 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] Don't send missing $wgVisualEditorTabMessages to the browser

https://gerrit.wikimedia.org/r/817250

Krinkle assigned this task to DannyS712.
Krinkle subscribed.

This looks good enough to me now.

Understanding/Assumptions:

  • The wgVisualEditorConfig data blob is one of two notable VE-related data blobs. The other one being the dedicated VisualEditorDataModule.
  • The wgVisualEditorConfig data blob is requested proactively on every page view. VisualEditorDataModule is only loaded after clicking the "Edit" button.
  • I assume that any VE data that isn't needed by the VE init payload is presumably not part of wgVisualEditorConfig, thus there is not more we can avoid.
  • The wgVisualEditorConfig data blob is cached in localStorage for upto 30 days after being loaded via the mediawiki.base module. This means it is not actually "transferred" on every pageview, but rather only requested. In the majority of page views, it is obtained from browser's offline local storage at little to no cost.