Page MenuHomePhabricator

Don’t add site JS/CSS to api.php jsonfm/etc. (HTML) output
Closed, DuplicatePublic

Description

The “fm” API output formats, jsonfm (default), xmlfm, phpfm and rawfm, apparently include the wiki’s common.js and common.css; for instance, aswiki API output has some social media buttons:

Screen Shot 2021-12-15 at 13.16.34.png (480×640 px, 37 KB)

(Adding debug=true also enables ResourceLoader debug mode.) This seems highly unexpected and not very beneficial – most site JS/CSS is probably not prepared for this unusual environment, and will produce random errors, like this one on aswiki:

Uncaught TypeError: mw.user.isAnon is not a function

Let’s get rid of this?

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Krinkle triaged this task as Medium priority.Jan 10 2022, 8:02 PM
Krinkle moved this task from Inbox to Backlog: Maintenance on the Performance-Team board.
Krinkle removed a project: MediaWiki-ResourceLoader.

I believe we originally left it this way so as to keep api.php as "normal" as possible within its already unusual use of the Skin system (we might handle this differently if we did it again today). So allowing experimentation and innovation through gadgets and user scripts seems like we might as well.

I recognise that it is not uncommon for interface admins to forget about non-default skins, but I don't know if that's reason enough by itself. For one, I would expect these to fail without visual problems given ResourceLoader's isolated execution model. And beyond that, sites have control over these the same as way for any other skins. E.g. if a gadget isn't compatible or intended for use in Timeless, its definition can be set to something like skins=vector,minerva,vector22. Likewise, common site scripts intended for specific skins only can also use MediaWiki:<Skin>.js instead of Common.js (or use a default/hidden gadget like I did on mediawiki.org).

Another example of commonly broken scripts is ContentTranslation (Special:ContentTranslation) which has also begun using the Skin system (overview of up/downsides at T291193#7360586).

Having said that, I don't really mind either way, and at this time I'm not (yet) aware of anyone using this for good. We could ask Wikitech-ambassadors if we want to know if anyone's making use of this.

(Just to mention the actual skin name implied by your comment, it’s apioutput apparently.)