41

Is there any way of specifying an order to the automatically loaded css or js files loaded by Meteor.

Searched the docs and can't find anything.

I ask because I'm at the playing about stage, and am trying to use Twitter Bootstrap with Meteor. In the examples that come with Bootstrap the base bootstrap.css is always loaded before the bootstrap-responsive.css.

Any ideas?

pharrisee
  • 465
  • 1
  • 4
  • 8
  • 1
    partially answering my own question here. It seems that the files are loaded depth first, as in the files in the deepest part of the hierarchy, and then alphabetically? Is this right? – pharrisee Apr 11 '12 at 15:36
  • I've filed an [issue](https://github.com/meteor/meteor/issues/381) for the meteor team to document the order of loading files. – Dan Dascalescu Oct 14 '12 at 07:55
  • 2
    you could remove the bootstrap package and add the files to the public folder. Once the files are in there, you can link them in your html. – Micha Roon Mar 19 '13 at 22:31
  • I'm thinking one way of doing this is to use gulp to create your JS and CSS file in the right order first. – Archimedes Trajano Mar 02 '16 at 21:51

3 Answers3

43

This question has since been answered in http://docs.meteor.com/

The JavaScript and CSS files in an application are loaded according to these rules:

Files in the lib directory at the root of your application are loaded first.

Files that match main.* are loaded after everything else.

Files in subdirectories are loaded before files in parent directories, so that files in the deepest subdirectory are loaded first (after lib), and files in the root directory are loaded last (other than main.*).

Within a directory, files are loaded in alphabetical order by filename.

These rules stack, so that within lib, for example, files are still loaded in alphabetical order; and if there are multiple files named main.js, the ones in subdirectories are loaded earlier.

jpeskin
  • 2,801
  • 4
  • 28
  • 27
16

You are correct, user files are loaded depth first, alphabetically otherwise.

https://guide.meteor.com/structure.html#load-order

lib/ directories and main.* files are special cases.

Packages can also alter load order, but I don't think any of the default packages do that.

bryan kennedy
  • 6,969
  • 5
  • 43
  • 64
n1mmy
  • 2,489
  • 1
  • 19
  • 15
  • @danrhul - thanks to Geoff Schmidt's [commit from about a year ago](https://github.com/meteor/meteor/commit/d40be780fbcbdb370914403259a3f7ac99e0b075) the logic is now included in the docs under [Structuring your app](http://docs.meteor.com/#structuringyourapp) – James Manning Oct 16 '13 at 02:59
0

Running on windows, the other solutions didn't work for me so I just put all the js files into 1 folder and just number them. Meteor loads them in alphabetical order.

mark pavlis
  • 681
  • 1
  • 5
  • 9