Talk:Recommendations for gadget developers on Wikimedia wikis

Cater for the situation where these elements do not exist
I actually consider the  more of an antipattern than. I encountered multiple times that someone reports that a gadget doesn’t do anything, and when I asked them for the stack trace, it turned out that there wasn’t any. These are often caused by such structures: (jQuery is especially prone to such issues, as its signature doesn’t make it obvious that there’s a no-op when the selector doesn’t match).

There are three acceptable solutions IMO: Tacsipacsi (talk) 02:12, 11 January 2023 (UTC)
 * Provide an actual fallback if possible. For example, if there’s no, insert the node to the beginning of the content, or wherever it makes sense.
 * Replace the  with a   call if no actual fallback can be provided but the gadget is still useful without this part. The gadget functionality will be partial if   goes away, but the cause will appear in the console, and other parts of the gadget will continue to work.
 * Don’t care, i.e. do what you put in . If the gadget cannot do anything useful without , fail fast and loud so that someone quickly notices it, and the gadget can be fixed or disabled.