Thread:Project:Support desk/Loading race condition for javascript/reply

It would help if you mentioned which prototype functions you are using. Because unless it is part of of jQuery core, it is likely defined by one of the many plugins. And in order to use those, you need to declare a dependency.

The race condition you refer to would normally consistently fail if you don't declare a dependency on the modules you require. Eg. if you make use of  (defined by jquery.cookie) and don't anywhere declare that your module or (depending on how you load that MediaWiki:BreedingCalculator.js file, a) raw-loaded script depends on this module, it will not be loaded (we don't load 200+ modules on every page, only what is specifically requested or depended on).

The modules specifically requested by  will have themselves and all their dependencies load in parallel, and executed in the proper order to satisfy dependencies.

If you're experiencing a race condition, it is likely that some other (complete unrelated) module is using the same dependency, except that that one did declare the dependency. And since they load in parallel, your script may or may not execute in time.

On the server-side, you can declare dependences when registering the module.

In Gadgets, declare dependencies on MediaWiki:Gadgets-definition with the  syntax.

Inside a raw-loaded script, declare dependencies inline by wrapping the code in.