As part of the desktop improvements project we spent time investing in the core code that powers skins. With support from volunteers (the majority of this support coming from the prolific @Ammarpad), we identified code patterns and made changes to the MediaWiki-Core-Skin-Architecture to retroactively define a data layer API for generating a skin.
Once this was in place, we updated the legacy MediaWiki skins Monobook, Modern, CologneBlue to use Mustache to bring them in line with how Vector and Minerva were built.
The rationale for doing this was as follows:
- We wanted to centralize code into core, and standardize markup, to make it easier to roll out changes to all skins. Often developers found ourselves updating every skin every time we wanted to make a small change or forced to use specific classes to markup elements (e.g. T248137, T253938).
- We wanted to move away from server-side technologies to client-side technologies to play better to the strengths of frontend engineers and designers who worked on skins.
- Since many of these skins do not see active development, we wanted to support them better by reducing lines of code
- Many of the skins didn't support certain extensions because they used different code (for example certain skins didn't run hooks that were used by certain features) e.g. 6ce3ce1acb68f0a3fdf1bd8824f6d0717bffa320 T259400
- Stop supporting features in core that were never widely adopted e.g. T97892
This process reduced 106,078 lines of code to 85,310 lines of code - a 20% decrease.
Before the change around 45% of skin code was PHP. After the change PHP only accounted for 15% of the code.
It would be great to in the future migrate Timeless too, but Timeless using the legacy skin platform does help keep us accountable for ensuring we continue to support skins built on this platform.
Methodology for result
To measure code makeup we can run github-linguist before and after the change.
After change (abe94aa4082dbc4f8b9060528a1b4fea2d0af0f1)
After change (c74d67950b6de2bafd9e3b1e05e601caaa7d9452)
After change (bf06742467f6c6c2bb42367f2e073eb26ed5d495)
The total number of lines of PHP before the change: 47954
After the change: 12378 lines of PHP
(This is a 74% decrease in lines of code)