Thread:Talk:MediaWiki vendors/WikiEditor toolbars, JavaScript dependencies, and asychronous behavior/reply (2)

As Maiden taiwan stated above, we've been having some problems with asynchronous behavior in JavaScript files.

Let me first say that the ResourceLoader is a wonderful part of the software. Thanks goes out to everyone who contributed to this project &mdash; it's made my life much better. That being said, I don't think that I and my team have figure out how to properly take advantage of it's benefits.

We are currently using the ResourceLoader to load modules, some of which contain JavaScript. The dependencies are made explicit in the registering of the ResourceLoader, and they execute in the proper order on the client side. In many of these JavaScript files we wrap our code in a jQuery .ready callback. Since these JavaScript files have dependencies on one-another (as laid out in the RL,) they need to be executed in the correct order to work properly. We're finding that when using jQuery's .ready (or similar) function, the callbacks seem to execute in different (unexepected, browser-dependent) order. This causes errors.
 * General

Customizing the WikiEditor-toolbar is one of the specific cases where we've encountered problems. First, the WikiEditor provides no good events to bind to once the toolbar is loaded. This is not a problem because there is a documented work-around. However, our JavaScript code needs to execute in the proper order, which it is not. We have about four JavaScript files that add custom toolbars, sections, and groups.
 * WikiEditor extension as a specific example


 * My questions
 * It recently dawned on me that executing our code within a  callback might not be necessary as the JavaScript for each ResourceLoader module is executed in its own callback on the client-side. This should provide the necessary scope to avoid clobbering global variables along with getting executed at the proper time. Is this a correct assumption to make?
 * Is it a good idea to avoid binding our code to jQuery's  event?

I'm going to test this theory and post to /  with questions.