How to avoid redefining requirejs in plugin when another plugin also uses requirejs

You could take a look at the enqueued scripts in $wp_scripts ($wp_scripts->registered), but the naming could be different (“it’s requirejs but let’s call it loadstuffjs, just because”), so I doubt it’ll be close to perfect.

Also, your plugin might be loaded before the other plugin, and they might trigger the problem without you having any control.

Maybe make loading requirejs optional (but enabled) and tell people that they ought to try disable loading it if they run into this problem (the reason being that the “other” requirejs will be loaded and work just fine). Also, I’d get a list of plugin/themes that you have these problems with and inform the user about incompatibility and ask whether they want to enable your “compatibility mode” (aka not loading requirejs through your plugin).

tech