A slightly more robust implementation can be found here; someone wanted the "prefix" functionality that Extension:Loops provides in its forargs parser function so I added support for that too.
You should ideally be authoring with TemplateStyles these days, which will better guarantee your order.
Unfortunately, not all wikis have that installed (pre‑1.44) or enabled (1.44 or later).
TemplateStyles has been available since 1.30 which was released in 2017, nearly a decade ago. Every supported version of MediaWiki can run TemplateStyles. The set of hosts documented at mwwiki:Extension:TemplateStyles is most of the large ones. So I'm not sure what this comment is actually about.
A better option would be to add a function to check whether the expensive function count can be incremented up to n times, something like:
lua
--- @param amount? number
--- @return number
function mw.canCallExpensiveFunctions(amount)
libraryUtil.checkType("mw.canCallExpensiveFunctions", 1, amount, "number", true);
amount = amount or 1;
File description pages can exist without a file existing (manually created pages in the File namespace) and files can exist without description pages existing (Commons files without local description pages), so title.exists and title.file.exists are independent. I propose declining this task.
...is a valid rule for setting the element's background-image-source to url('pr0n.gif'), but it's not particularly hard to detect that when parsing the custom properties themselves, since we never want to allow anyurl() values at all. Custom properties do not really make it any easier to hide those invalid values, since the substitution results are never fed back into the CSS parser.