How do I change the order in which Meteor loads Javascript files?

Solution 1:

According to the Meteor documentation, files are currently loaded in this order:

  1. Files in [project_root]/lib are loaded first
  2. Files are sorted by directory depth. Deeper files are loaded first.
  3. Files are sorted in alphabetical order.
  4. main.* files are loaded last.

Source: http://docs.meteor.com/#structuringyourapp

Solution 2:

Not a solution for all scenarios, but I think ideally anything that is dependent on other code would be placed in a Meteor.startup function, to ensure everything is already loaded.