CodeMirror must not embed 5KB of config on every page view
Closed, ResolvedPublic

Description

I just noticed this huge blob being included on every page view of en.wikipedia.org, test2.wikipedia.org and presumably lots of other wikis as well. This wasn't there not so long ago, so either the extension regressed or it wasn't installed or enabled in this way before.

This is will likely impact page render time due to this configuration being inside the <head> and thus slows down retrieval of more important things (like stylesheets and article content). With the goal of trying to squeeze the first stylesheet and above-the-fold content into 12KB, we can't give 5KB of that just for CodeMirror configuration. (T127328)

This configuration should be removed from the default output and moved to a DataModule. Given VisualEditor supports a plugin list with module names, this shouldn't pose any problem.

5659 bytes
"extCodeMirrorConfig":{"pluginModules":[],"tagModes":{"ref":"text/mediawiki","pre":"mw-tag-pre","nowiki":"mw-tag-nowiki"},"tags":{"pre":true,"nowiki":true,"gallery":true,"indicator":true,"timeline":true,"hiero":true,"charinsert":true,"ref":true,"references":true,"inputbox":true,"imagemap":true,"source":true,"syntaxhighlight":true,"poem":true,"section":true,"score":true,"templatedata":true,"math":true,"ce":true,"chem":true,"graph":true,"maplink":true,"categorytree":true},"doubleUnderscore":[{"__notoc__":"notoc","__nogallery__":"nogallery","__forcetoc__":"forcetoc","__toc__":"toc","__noeditsection__":"noeditsection","__notitleconvert__":"notitleconvert","__notc__":"notitleconvert","__nocontentconvert__":"nocontentconvert","__nocc__":"nocontentconvert"},{"__NEWSECTIONLINK__":"newsectionlink","__NONEWSECTIONLINK__":"nonewsectionlink","__HIDDENCAT__":"hiddencat","__INDEX__":"index","__NOINDEX__":"noindex","__STATICREDIRECT__":"staticredirect","__NOGLOBAL__":"noglobal","__DISAMBIG__":"disambiguation"}],"functionSynonyms":[{"ns":"ns","nse":"nse","urlencode":"urlencode","lcfirst":"lcfirst","ucfirst":"ucfirst","lc":"lc","uc":"uc","localurl":"localurl","localurle":"localurle","fullurl":"fullurl","fullurle":"fullurle","canonicalurl":"canonicalurl","canonicalurle":"canonicalurle","formatnum":"formatnum","grammar":"grammar","gender":"gender","plural":"plural","bidi":"bidi","#language":"language","padleft":"padleft","padright":"padright","anchorencode":"anchorencode","filepath":"filepath","pageid":"pageid","int":"int","#special":"special","#speciale":"speciale","#tag":"tag","#formatdate":"formatdate","#dateformat":"formatdate","noexternallanglinks":"noexternallanglinks","#property":"property","#statements":"statements","#if":"if","#ifeq":"ifeq","#switch":"switch","#ifexist":"ifexist","#ifexpr":"ifexpr","#iferror":"iferror","#time":"time","#timel":"timel","#expr":"expr","#rel2abs":"rel2abs","#titleparts":"titleparts","#lst":"lst","#section":"lst","#lstx":"lstx","#section-x":"lstx","#lsth":"lsth","#section-h":"lsth","#target":"target","#babel":"babel","#coordinates":"coordinates","#invoke":"invoke","#related":"related","#assessment":"assessment","#categorytree":"categorytree","#pagesusingpendingchanges":"pagesusingpendingchanges","pendingchangelevel":"pendingchangelevel","articlepath":"articlepath","server":"server","servername":"servername","scriptpath":"scriptpath","stylepath":"stylepath","wbreponame":"wbreponame","numberofwikis":"numberofwikis"},{"NUMBEROFPAGES":"numberofpages","NUMBEROFUSERS":"numberofusers","NUMBEROFACTIVEUSERS":"numberofactiveusers","NUMBEROFARTICLES":"numberofarticles","NUMBEROFFILES":"numberoffiles","NUMBEROFADMINS":"numberofadmins","NUMBERINGROUP":"numberingroup","NUMINGROUP":"numberingroup","NUMBEROFEDITS":"numberofedits","DEFAULTSORT":"defaultsort","DEFAULTSORTKEY":"defaultsort","DEFAULTCATEGORYSORT":"defaultsort","PAGESINCATEGORY":"pagesincategory","PAGESINCAT":"pagesincategory","PAGESIZE":"pagesize","PROTECTIONLEVEL":"protectionlevel","PROTECTIONEXPIRY":"protectionexpiry","NAMESPACEE":"namespacee","NAMESPACENUMBER":"namespacenumber","TALKSPACE":"talkspace","TALKSPACEE":"talkspacee","SUBJECTSPACE":"subjectspace","ARTICLESPACE":"subjectspace","SUBJECTSPACEE":"subjectspacee","ARTICLESPACEE":"subjectspacee","PAGENAME":"pagename","PAGENAMEE":"pagenamee","FULLPAGENAME":"fullpagename","FULLPAGENAMEE":"fullpagenamee","ROOTPAGENAME":"rootpagename","ROOTPAGENAMEE":"rootpagenamee","BASEPAGENAME":"basepagename","BASEPAGENAMEE":"basepagenamee","SUBPAGENAME":"subpagename","SUBPAGENAMEE":"subpagenamee","TALKPAGENAME":"talkpagename","TALKPAGENAMEE":"talkpagenamee","SUBJECTPAGENAME":"subjectpagename","ARTICLEPAGENAME":"subjectpagename","SUBJECTPAGENAMEE":"subjectpagenamee","ARTICLEPAGENAMEE":"subjectpagenamee","REVISIONID":"revisionid","REVISIONDAY":"revisionday","REVISIONDAY2":"revisionday2","REVISIONMONTH":"revisionmonth","REVISIONMONTH1":"revisionmonth1","REVISIONYEAR":"revisionyear","REVISIONTIMESTAMP":"revisiontimestamp","REVISIONUSER":"revisionuser","CASCADINGSOURCES":"cascadingsources","NAMESPACE":"namespace","DISPLAYTITLE":"displaytitle","!":"!","CURRENTMONTH":"currentmonth","CURRENTMONTH2":"currentmonth","CURRENTMONTH1":"currentmonth1","CURRENTMONTHNAME":"currentmonthname","CURRENTMONTHNAMEGEN":"currentmonthnamegen","CURRENTMONTHABBREV":"currentmonthabbrev","CURRENTDAY":"currentday","CURRENTDAY2":"currentday2","CURRENTDAYNAME":"currentdayname","CURRENTYEAR":"currentyear","CURRENTTIME":"currenttime","CURRENTHOUR":"currenthour","LOCALMONTH":"localmonth","LOCALMONTH2":"localmonth","LOCALMONTH1":"localmonth1","LOCALMONTHNAME":"localmonthname","LOCALMONTHNAMEGEN":"localmonthnamegen","LOCALMONTHABBREV":"localmonthabbrev","LOCALDAY":"localday","LOCALDAY2":"localday2","LOCALDAYNAME":"localdayname","LOCALYEAR":"localyear","LOCALTIME":"localtime","LOCALHOUR":"localhour","SITENAME":"sitename","CURRENTWEEK":"currentweek","CURRENTDOW":"currentdow","LOCALWEEK":"localweek","LOCALDOW":"localdow","REVISIONSIZE":"revisionsize","CURRENTVERSION":"currentversion","CURRENTTIMESTAMP":"currenttimestamp","LOCALTIMESTAMP":"localtimestamp","DIRECTIONMARK":"directionmark","DIRMARK":"directionmark","CONTENTLANGUAGE":"contentlanguage","CONTENTLANG":"contentlanguage","PAGELANGUAGE":"pagelanguage"}],"urlProtocols":"bitcoin\\:|ftp\\:\\/\\/|ftps\\:\\/\\/|geo\\:|git\\:\\/\\/|gopher\\:\\/\\/|http\\:\\/\\/|https\\:\\/\\/|irc\\:\\/\\/|ircs\\:\\/\\/|magnet\\:|mailto\\:|mms\\:\\/\\/|news\\:|nntp\\:\\/\\/|redis\\:\\/\\/|sftp\\:\\/\\/|sip\\:|sips\\:|sms\\:|ssh\\:\\/\\/|svn\\:\\/\\/|tel\\:|telnet\\:\\/\\/|urn\\:|worldwind\\:\\/\\/|xmpp\\:|\\/\\/","linkTrailCharacters":"/^([a-z]+)(.*)$/sD"}

Unrelated: At least url protocols is redundant given wgUrlProtocols is already available on all pages via the startup module.
In addition, beware of the caveat of using page output: HTTP caching. Using a data module is better for cache consistency, given that data modules will always atomically share the same snapshot in time as the javascript code, whereas use of page output means the config values are stuck in static http cache, but the JS code will update independently, which can certainly cause maintenance complications (or bugs).

Krinkle created this task.Aug 3 2017, 10:58 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptAug 3 2017, 10:58 PM
Krinkle triaged this task as High priority.Aug 3 2017, 10:58 PM
Krinkle moved this task from Inbox to Radar on the Performance-Team board.
Krinkle updated the task description. (Show Details)
Krinkle added a project: Community-Tech.
Krinkle added a subscriber: MaxSem.

(Marking as blocking T168053, technically not part of the branch but a config change this week, but making sure it's not forgotten and we don't roll forward another week without addressing this.)

Krinkle updated the task description. (Show Details)Aug 3 2017, 11:08 PM
Restricted Application added a subscriber: Danmichaelo. · View Herald TranscriptAug 3 2017, 11:08 PM
MaxSem claimed this task.Aug 3 2017, 11:14 PM

Reverted the wide-scale deployment for now.

Change 370129 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/CodeMirror@master] Move JS config vars from page HTML into RL module

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

Possibly there is one other problem, I see the requests to /w/undefined when CodeMirror is enabled. Maybe problem is only on my test wiki, please check it on before the wide-scale deployment.

Pastakhov added a comment.EditedAug 4 2017, 9:20 AM

The bug described above happens on FF. Since WikiEditor does not designed to work with changeable icons, the one requires the icon defined when initializing. Because we use other approach to define the icons, WikiEditor inserts style to the button style="background-image: url(&quot;undefined&quot;);".
Despite the fact that it is removed later, FF trying load undefined background any case .

Seems the bug should be fixed before the wide-scale deployment.

P.S. The ticket created: T172500

Change 370129 merged by jenkins-bot:
[mediawiki/extensions/CodeMirror@master] Move JS config vars from page HTML into RL module

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

DannyH added a subscriber: DannyH.
MaxSem closed this task as Resolved.Aug 4 2017, 6:33 PM
kaldari moved this task from Ready to Done on the Community-Tech-Sprint board.Aug 4 2017, 9:47 PM

Change 370904 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/CodeMirror@wmf/1.30.0-wmf.12] Move JS config vars from page HTML into RL module

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

Change 370904 merged by jenkins-bot:
[mediawiki/extensions/CodeMirror@wmf/1.30.0-wmf.12] Move JS config vars from page HTML into RL module

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

DannyH moved this task from Untriaged to Archive on the Community-Tech board.