Many gadgets are loaded in environments they are not ever used. For example:
* the ReferenceTooltips gadget loads on all pages, but can only be used in devices where a mouse is available (and thus it is possible to hover over references).
* Some gadgets require a certain screen size
* Some gadgets rely on a certain editor being available e.g. mobile editor
* Some gadgets add functionality that is not needed on the mobile Minerva skin. For example section collapsing is added on Minerva but only on mobile site. The MultimediaViewer is different on mobile and desktop (tracked in T65504)
* MobileFrontend removes content from the article which means gadgets don't work as expected e.g. removal of navboxes breaks the navboxNavigation gadget. (T124168)
Originally suggested by @tgr in T127268#8974464 we should provide "skipFunctions" for gadgets that allow gadget code to not load in certain circumstance.
Initially skipFunctions could be defined inside the Gadget extension and Gadget definitions could use them by reference
e.g. This might look something like this where requires=!touch-device adds a skip function relating to touch device support.
```
var isTouchDevice = 'ontouchstart' in document.documentElement;
var desktopResolution = window.innerWidth >= 1000;
```
```
* ReferenceTooltips[ResourceLoader|default|requires=!touch-device,desktop-resolution|skins=vector,vector-2022,monobook,timeless,modern,cologneblue|type=general|dependencies=mediawiki.cookie,jquery.client]|ReferenceTooltips.js|ReferenceTooltips.css
```