The "[[ https://grafana.wikimedia.org/dashboard/db/mobile-2g?orgId=1&from=1501082591633&to=1503501791637 | CSS Size (Barack Obama - en.m) ]]" graph shows that the CSS size for this page has been fluctuating has been increasing and decreasing cyclically by a consistent amount of bytes for almost a year.
6 month period:
http://wpt.wmftest.org/result/180614_EZ_GR/1/details/#waterfall_view_step1 (makes [[ https://en.m.wikipedia.org/w/load.php?debug=false&lang=en&modules=ext.cite.styles%7Cext.math.styles%7Cmediawiki.hlist%7Cmediawiki.ui.button%2Cicon%7Cskins.minerva.base.reset%2Cstyles%7Cskins.minerva.content.styles%7Cskins.minerva.icons.images%7Cskins.minerva.tablet.styles&only=styles&skin=minerva | ext.math.styles ]] request
with http://wpt.wmftest.org/result/180612_QJ_GW/1/details/#waterfall_view_step1 (no math request)
The Barack Obama page does not have any Math equations.
I am concerned that user specific preferences are causing parser cache pollution and this problem may be a larger performance problem then we are aware of.
After some investigation (see detailed developer notes) I have managed to narrow this down to a Lua module that reads Wikidata data, which in turn leads to the Math module unexpectedly being added.
== Developer notes
Looking at the underlying code there is a troublesome note "This affects the page caching behavior."
I see the page rendering hash is linked to the user option but not the current user:
Given the regularity of the CSS change, it seems this isn't related to edit activity so I would suspect there is something funky with the caching here and the style is being added where it shouldn't be.
The style should only be added if the **chem** or **math** parser function is used. The only other place ext.math.styles is added relates to Wikidata: [[ https://github.com/wikimedia/mediawiki-extensions-Math/blob/670f0bb8f95b8d9ac7994ab3ff45a7bb8e91d185/src/MathWikidataHook.php#L45 | Wikidata hook]]
== Replication steps
* Ensure https://wikidata.beta.wmflabs.org/wiki/Q361812 has a site link to https://en.wikipedia.beta.wmflabs.org/wiki/T173949 and has an inception field. IF not add one pointing it to 2017.
* Visit [desktop] https://en.wikipedia.beta.wmflabs.org/wiki/T173949?action=purge incognito and purge page
* Visit [desktop] (hard refresh) https://en.wikipedia.beta.wmflabs.org/wiki/T173949 incognito and verify that mw.loader.getState('ext.math.styles') === 'registered' is true
* Visit [mobile] https://en.m.wikipedia.beta.wmflabs.org/wiki/T173949 and note that mw.loader.getState('ext.math.styles') === 'registered' is now false (Expected: should be true)
* Purge [mobile] https://en.m.wikipedia.beta.wmflabs.org/wiki/T173949?action=purge and verify that mw.loader.getState('ext.math.styles') === 'registered' is still false
* Visit [desktop] https://en.wikipedia.beta.wmflabs.org/wiki/T173949 and see that mw.loader.getState('ext.math.styles') === 'registered' is now false. (Expected: should be true)
* Remove wikilink on https://wikidata.beta.wmflabs.org/wiki/Q361812 to https://en.wikipedia.beta.wmflabs.org/wiki/T173949
* Refresh page and see that mw.loader.getState('ext.math.styles') === 'registered' is now true
= Developer notes
This only seems to happen when a page is associated with a Wikidata entry. When I remove the wikilink on https://www.wikidata.org/wiki/Q4115189 the problem magically goes away
It also seems to go away when the template "[[ https://en.wikipedia.org/wiki/Template:Internet_Archive_author?action=edit | Internet Archive author ]]" has been removed.
The code inside https://en.wikipedia.org/wiki/Module:Internet_Archive does seem to make use of wikibase - making a call to mw.wikibase.getEntityObject().
I connected https://wikidata.beta.wmflabs.org/wiki/Q361812 to https://en.wikipedia.beta.wmflabs.org/wiki/T173949 and re-ran the experiment but it failed. I updated the module, still no luck, however when I added [[ https://wikidata.beta.wmflabs.org/w/index.php?title=Q361812&type=revision&diff=1032719&oldid=1032718 | an inception (start date) field to the Wikidata item ]] the math module started to get pulled in.
=== Wed 20th June 2018
I've narrowed it down ever further https://en.m.wikipedia.beta.wmflabs.org/wiki/T173949-2 with a simplified module https://en.wikipedia.beta.wmflabs.org/wiki/Module:T173949
All this module does is call the method [[ https://github.com/wikimedia/mediawiki-extensions-Wikibase/blob/db5e6c729ea1de1e1f77f11265077ced828a13c6/client/includes/DataAccess/Scribunto/WikibaseLuaEntityBindings.php#L83 | formatPropertyValues ]]
This method seems to trigger the load of ext.math.styles in the mobile view.
Next step would be to replicate this on an environment where I can see exactly what's going on.
If an article page is connected to a Wikidata entry which has an inception field AND ` entity:formatPropertyValues( 'P569' )` is invoked inside a Lua module the ext.math.styles module is unexpectedly pulled into the mobile view.
= Acceptance criteria
 ext.math.styles should not be loaded on mobile for a page which does not have Math