When manipulate the toolbar with user or site javascript you have to wait until 'mediawiki.action.edit' is "ready", but the code
mw.loader.using( [ 'mediawiki.action.edit' ], function() {
...
});
will load 'mediawiki.action.edit' on each page. Adding a check for wgAction !== edit and submit is a solution, but for other modules you have to know, where it is running and adding that check, that is bad, when the condition is changed.
Having a method inside the loader, which allow executing a function after all dependency are ready without requesting the modules, can help here. When the page is ready and the dependency is not loaded, than the loader ignore this function.
For example:
mw.loader.usingIfExist( [ 'mediawiki.action.edit' ], function() {
...
});
will only executing the function when 'mediawiki.action.edit' is loaded on the page and will not requesting the module itself. When the module is not loaded, the function is ignored.
Version: unspecified
Severity: enhancement